Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_channel_id_helper.h
blob520fe485742e85e2f1b8451ac9a73ca58ce53107
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_
8 #include <map>
9 #include <string>
11 #include "base/callback.h"
12 #include "net/ssl/channel_id_store.h"
14 namespace net {
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
22 // some later point.
23 class BrowsingDataChannelIDHelper
24 : public base::RefCountedThreadSafe<BrowsingDataChannelIDHelper> {
25 public:
26 // Create a BrowsingDataChannelIDHelper instance for the given
27 // |request_context|.
28 static BrowsingDataChannelIDHelper* Create(
29 net::URLRequestContextGetter* request_context);
31 typedef base::Callback<
32 void(const net::ChannelIDStore::ChannelIDList&)>
33 FetchResultCallback;
35 // Starts the fetching process, which will notify its completion via
36 // callback.
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
40 // the UI thread.
41 virtual void DeleteChannelID(const std::string& server_id) = 0;
43 protected:
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 {
53 public:
54 CannedBrowsingDataChannelIDHelper();
56 // Add an ChannelID to the set of canned channel IDs that is
57 // returned by this helper.
58 void AddChannelID(
59 const net::ChannelIDStore::ChannelID& channel_id);
61 // Clears the list of canned channel IDs.
62 void Reset();
64 // True if no ChannelIDs are currently stored.
65 bool empty() const;
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;
74 private:
75 ~CannedBrowsingDataChannelIDHelper() override;
77 void FinishFetching();
79 typedef std::map<std::string, net::ChannelIDStore::ChannelID>
80 ChannelIDMap;
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_