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.
5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_CHANNEL_ID_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_CHANNEL_ID_HELPER_H_
11 #include "base/callback.h"
12 #include "net/ssl/channel_id_store.h"
15 class URLRequestContextGetter
;
18 // BrowsingDataChannelIDHelper is an interface for classes dealing with
19 // aggregating and deleting browsing data stored in the channel ID store.
20 // A client of this class need to call StartFetching from the UI thread to
21 // initiate the flow, and it'll be notified by the callback in its UI thread at
23 class BrowsingDataChannelIDHelper
24 : public base::RefCountedThreadSafe
<BrowsingDataChannelIDHelper
> {
26 // Create a BrowsingDataChannelIDHelper instance for the given
28 static BrowsingDataChannelIDHelper
* Create(
29 net::URLRequestContextGetter
* request_context
);
31 typedef base::Callback
<
32 void(const net::ChannelIDStore::ChannelIDList
&)>
35 // Starts the fetching process, which will notify its completion via
37 // This must be called only in the UI thread.
38 virtual void StartFetching(const FetchResultCallback
& callback
) = 0;
39 // Requests a single channel ID to be deleted. This must be called in
41 virtual void DeleteChannelID(const std::string
& server_id
) = 0;
44 friend class base::RefCountedThreadSafe
<BrowsingDataChannelIDHelper
>;
45 virtual ~BrowsingDataChannelIDHelper() {}
48 // This class is a thin wrapper around BrowsingDataChannelIDHelper that
49 // does not fetch its information from the ChannelIDService, but gets them
50 // passed as a parameter during construction.
51 class CannedBrowsingDataChannelIDHelper
52 : public BrowsingDataChannelIDHelper
{
54 CannedBrowsingDataChannelIDHelper();
56 // Add an ChannelID to the set of canned channel IDs that is
57 // returned by this helper.
59 const net::ChannelIDStore::ChannelID
& channel_id
);
61 // Clears the list of canned channel IDs.
64 // True if no ChannelIDs are currently stored.
67 // Returns the current number of channel IDs.
68 size_t GetChannelIDCount() const;
70 // BrowsingDataChannelIDHelper methods.
71 void StartFetching(const FetchResultCallback
& callback
) override
;
72 void DeleteChannelID(const std::string
& server_id
) override
;
75 ~CannedBrowsingDataChannelIDHelper() override
;
77 void FinishFetching();
79 typedef std::map
<std::string
, net::ChannelIDStore::ChannelID
>
81 ChannelIDMap channel_id_map_
;
83 FetchResultCallback completion_callback_
;
85 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataChannelIDHelper
);
88 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_CHANNEL_ID_HELPER_H_