Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Side by Side Diff: components/google/core/browser/google_url_tracker.h

Issue 1918083002: Convert //components/[f-n]* from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: … Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_ 5 #ifndef COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_
6 #define COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_ 6 #define COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_
7 7
8 #include <memory>
9
8 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
9 #include "base/callback_list.h" 11 #include "base/callback_list.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "components/google/core/browser/google_url_tracker_client.h" 14 #include "components/google/core/browser/google_url_tracker_client.h"
14 #include "components/keyed_service/core/keyed_service.h" 15 #include "components/keyed_service/core/keyed_service.h"
15 #include "net/base/network_change_notifier.h" 16 #include "net/base/network_change_notifier.h"
16 #include "net/url_request/url_fetcher.h" 17 #include "net/url_request/url_fetcher.h"
17 #include "net/url_request/url_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
19 20
20 class PrefService; 21 class PrefService;
21 22
(...skipping 29 matching lines...) Expand all
51 // The constructor does different things depending on which of these values 52 // The constructor does different things depending on which of these values
52 // you pass it. Hopefully these are self-explanatory. 53 // you pass it. Hopefully these are self-explanatory.
53 enum Mode { 54 enum Mode {
54 NORMAL_MODE, 55 NORMAL_MODE,
55 UNIT_TEST_MODE, 56 UNIT_TEST_MODE,
56 }; 57 };
57 58
58 static const char kDefaultGoogleHomepage[]; 59 static const char kDefaultGoogleHomepage[];
59 60
60 // Only the GoogleURLTrackerFactory and tests should call this. 61 // Only the GoogleURLTrackerFactory and tests should call this.
61 GoogleURLTracker(scoped_ptr<GoogleURLTrackerClient> client, Mode mode); 62 GoogleURLTracker(std::unique_ptr<GoogleURLTrackerClient> client, Mode mode);
62 63
63 ~GoogleURLTracker() override; 64 ~GoogleURLTracker() override;
64 65
65 // Register user preferences for GoogleURLTracker. 66 // Register user preferences for GoogleURLTracker.
66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 67 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
67 68
68 69
69 // Returns the current Google homepage URL. 70 // Returns the current Google homepage URL.
70 const GURL& google_url() const { return google_url_; } 71 const GURL& google_url() const { return google_url_; }
71 72
72 // Requests that the tracker perform a server check to update the Google URL 73 // Requests that the tracker perform a server check to update the Google URL
73 // as necessary. If |force| is false, this will happen at most once per 74 // as necessary. If |force| is false, this will happen at most once per
74 // network change, not sooner than five seconds after startup (checks 75 // network change, not sooner than five seconds after startup (checks
75 // requested before that time will occur then; checks requested afterwards 76 // requested before that time will occur then; checks requested afterwards
76 // will occur immediately, if no other checks have been made during this run). 77 // will occur immediately, if no other checks have been made during this run).
77 // If |force| is true, and the tracker has already performed any requested 78 // If |force| is true, and the tracker has already performed any requested
78 // check, it will check again. 79 // check, it will check again.
79 void RequestServerCheck(bool force); 80 void RequestServerCheck(bool force);
80 81
81 scoped_ptr<Subscription> RegisterCallback( 82 std::unique_ptr<Subscription> RegisterCallback(
82 const OnGoogleURLUpdatedCallback& cb); 83 const OnGoogleURLUpdatedCallback& cb);
83 84
84 private: 85 private:
85 friend class GoogleURLTrackerTest; 86 friend class GoogleURLTrackerTest;
86 friend class SyncTest; 87 friend class SyncTest;
87 88
88 static const char kSearchDomainCheckURL[]; 89 static const char kSearchDomainCheckURL[];
89 90
90 // net::URLFetcherDelegate: 91 // net::URLFetcherDelegate:
91 void OnURLFetchComplete(const net::URLFetcher* source) override; 92 void OnURLFetchComplete(const net::URLFetcher* source) override;
(...skipping 11 matching lines...) Expand all
103 // Called when the five second startup sleep has finished. Runs any pending 104 // Called when the five second startup sleep has finished. Runs any pending
104 // fetch. 105 // fetch.
105 void FinishSleep(); 106 void FinishSleep();
106 107
107 // Starts the fetch of the up-to-date Google URL if we actually want to fetch 108 // Starts the fetch of the up-to-date Google URL if we actually want to fetch
108 // it and can currently do so. 109 // it and can currently do so.
109 void StartFetchIfDesirable(); 110 void StartFetchIfDesirable();
110 111
111 CallbackList callback_list_; 112 CallbackList callback_list_;
112 113
113 scoped_ptr<GoogleURLTrackerClient> client_; 114 std::unique_ptr<GoogleURLTrackerClient> client_;
114 115
115 GURL google_url_; 116 GURL google_url_;
116 scoped_ptr<net::URLFetcher> fetcher_; 117 std::unique_ptr<net::URLFetcher> fetcher_;
117 int fetcher_id_; 118 int fetcher_id_;
118 bool in_startup_sleep_; // True if we're in the five-second "no fetching" 119 bool in_startup_sleep_; // True if we're in the five-second "no fetching"
119 // period that begins at browser start. 120 // period that begins at browser start.
120 bool already_fetched_; // True if we've already fetched a URL once this run; 121 bool already_fetched_; // True if we've already fetched a URL once this run;
121 // we won't fetch again until after a restart. 122 // we won't fetch again until after a restart.
122 bool need_to_fetch_; // True if a consumer actually wants us to fetch an 123 bool need_to_fetch_; // True if a consumer actually wants us to fetch an
123 // updated URL. If this is never set, we won't 124 // updated URL. If this is never set, we won't
124 // bother to fetch anything. 125 // bother to fetch anything.
125 // Consumers should register a callback via 126 // Consumers should register a callback via
126 // RegisterCallback(). 127 // RegisterCallback().
127 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_; 128 base::WeakPtrFactory<GoogleURLTracker> weak_ptr_factory_;
128 129
129 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker); 130 DISALLOW_COPY_AND_ASSIGN(GoogleURLTracker);
130 }; 131 };
131 132
132 #endif // COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_ 133 #endif // COMPONENTS_GOOGLE_CORE_BROWSER_GOOGLE_URL_TRACKER_H_
OLDNEW
« no previous file with comments | « components/flags_ui/flags_state_unittest.cc ('k') | components/google/core/browser/google_url_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698