1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef NET_EXTRAS_SQLITE_SQLITE_CHANNEL_ID_STORE_H_
6#define NET_EXTRAS_SQLITE_SQLITE_CHANNEL_ID_STORE_H_
7
8#include <list>
9#include <string>
10
11#include "base/callback_forward.h"
12#include "base/compiler_specific.h"
13#include "base/macros.h"
14#include "base/memory/ref_counted.h"
15#include "net/ssl/default_channel_id_store.h"
16
17namespace base {
18class FilePath;
19class SequencedTaskRunner;
20}
21
22class GURL;
23
24namespace net {
25
26// Implements the DefaultChannelIDStore::PersistentStore interface
27// in terms of a SQLite database. For documentation about the actual member
28// functions consult the documentation of the parent class
29// DefaultChannelIDStore::PersistentCertStore.
30class SQLiteChannelIDStore : public DefaultChannelIDStore::PersistentStore {
31 public:
32  // Create or open persistent store in file |path|. All I/O tasks are performed
33  // in background using |background_task_runner|.
34  SQLiteChannelIDStore(
35      const base::FilePath& path,
36      const scoped_refptr<base::SequencedTaskRunner>& background_task_runner);
37
38  // DefaultChannelIDStore::PersistentStore:
39  virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE;
40  virtual void AddChannelID(
41      const DefaultChannelIDStore::ChannelID& channel_id) OVERRIDE;
42  virtual void DeleteChannelID(
43      const DefaultChannelIDStore::ChannelID& channel_id) OVERRIDE;
44  virtual void SetForceKeepSessionState() OVERRIDE;
45
46  // Delete channel ids from servers in |server_identifiers|.
47  void DeleteAllInList(const std::list<std::string>& server_identifiers);
48
49 private:
50  virtual ~SQLiteChannelIDStore();
51
52  class Backend;
53
54  scoped_refptr<Backend> backend_;
55
56  DISALLOW_COPY_AND_ASSIGN(SQLiteChannelIDStore);
57};
58
59}  // namespace net
60
61#endif  // NET_EXTRAS_SQLITE_SQLITE_CHANNEL_ID_STORE_H_
62