cros: Remove default pinned apps trial.
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_server_bound_cert_helper.h
blobb49546ddb741c5bb8b2c86a0b7bb6d5147d5619f
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_SERVER_BOUND_CERT_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_SERVER_BOUND_CERT_HELPER_H_
8 #include <map>
9 #include <string>
11 #include "base/callback.h"
12 #include "net/ssl/server_bound_cert_store.h"
14 class Profile;
16 // BrowsingDataServerBoundCertHelper is an interface for classes dealing with
17 // aggregating and deleting browsing data stored in the server bound cert store.
18 // A client of this class need to call StartFetching from the UI thread to
19 // initiate the flow, and it'll be notified by the callback in its UI thread at
20 // some later point.
21 class BrowsingDataServerBoundCertHelper
22 : public base::RefCountedThreadSafe<BrowsingDataServerBoundCertHelper> {
23 public:
25 // Create a BrowsingDataServerBoundCertHelper instance for the given
26 // |profile|.
27 static BrowsingDataServerBoundCertHelper* Create(Profile* profile);
29 typedef base::Callback<
30 void(const net::ServerBoundCertStore::ServerBoundCertList&)>
31 FetchResultCallback;
33 // Starts the fetching process, which will notify its completion via
34 // callback.
35 // This must be called only in the UI thread.
36 virtual void StartFetching(const FetchResultCallback& callback) = 0;
37 // Requests a single server bound cert to be deleted. This must be called in
38 // the UI thread.
39 virtual void DeleteServerBoundCert(const std::string& server_id) = 0;
41 protected:
42 friend class base::RefCountedThreadSafe<BrowsingDataServerBoundCertHelper>;
43 virtual ~BrowsingDataServerBoundCertHelper() {}
46 // This class is a thin wrapper around BrowsingDataServerBoundCertHelper that
47 // does not fetch its information from the ServerBoundCertService, but gets them
48 // passed as a parameter during construction.
49 class CannedBrowsingDataServerBoundCertHelper
50 : public BrowsingDataServerBoundCertHelper {
51 public:
52 CannedBrowsingDataServerBoundCertHelper();
54 // Return a copy of the ServerBoundCert helper. Only one consumer can use the
55 // StartFetching method at a time, so we need to create a copy of the helper
56 // every time we instantiate a cookies tree model for it.
57 CannedBrowsingDataServerBoundCertHelper* Clone();
59 // Add an ServerBoundCert to the set of canned server bound certs that is
60 // returned by this helper.
61 void AddServerBoundCert(
62 const net::ServerBoundCertStore::ServerBoundCert& server_bound_cert);
64 // Clears the list of canned server bound certs.
65 void Reset();
67 // True if no ServerBoundCerts are currently stored.
68 bool empty() const;
70 // Returns the current number of server bound certificates.
71 size_t GetCertCount() const;
73 // BrowsingDataServerBoundCertHelper methods.
74 virtual void StartFetching(const FetchResultCallback& callback) OVERRIDE;
75 virtual void DeleteServerBoundCert(const std::string& server_id) OVERRIDE;
77 private:
78 virtual ~CannedBrowsingDataServerBoundCertHelper();
80 void FinishFetching();
82 typedef std::map<std::string, net::ServerBoundCertStore::ServerBoundCert>
83 ServerBoundCertMap;
84 ServerBoundCertMap server_bound_cert_map_;
86 FetchResultCallback completion_callback_;
88 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataServerBoundCertHelper);
91 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_SERVER_BOUND_CERT_HELPER_H_