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_
11 #include "base/callback.h"
12 #include "net/ssl/server_bound_cert_store.h"
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
21 class BrowsingDataServerBoundCertHelper
22 : public base::RefCountedThreadSafe
<BrowsingDataServerBoundCertHelper
> {
25 // Create a BrowsingDataServerBoundCertHelper instance for the given
27 static BrowsingDataServerBoundCertHelper
* Create(Profile
* profile
);
29 typedef base::Callback
<
30 void(const net::ServerBoundCertStore::ServerBoundCertList
&)>
33 // Starts the fetching process, which will notify its completion via
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
39 virtual void DeleteServerBoundCert(const std::string
& server_id
) = 0;
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
{
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.
67 // True if no ServerBoundCerts are currently stored.
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
;
78 virtual ~CannedBrowsingDataServerBoundCertHelper();
80 void FinishFetching();
82 typedef std::map
<std::string
, net::ServerBoundCertStore::ServerBoundCert
>
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_