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

Side by Side Diff: components/suggestions/suggestions_service_impl.h

Issue 2869013004: Test SuggestionsServiceImpl without friending anything (Closed)
Patch Set: Created 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_SUGGESTIONS_SUGGESTIONS_SERVICE_IMPL_H_ 5 #ifndef COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_IMPL_H_
6 #define COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_IMPL_H_ 6 #define COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 bool UndoBlacklistURL(const GURL& url) override; 77 bool UndoBlacklistURL(const GURL& url) override;
78 void ClearBlacklist() override; 78 void ClearBlacklist() override;
79 79
80 // Determines which URL a blacklist request was for, irrespective of the 80 // Determines which URL a blacklist request was for, irrespective of the
81 // request's status. Returns false if |request| is not a blacklist request. 81 // request's status. Returns false if |request| is not a blacklist request.
82 static bool GetBlacklistedUrl(const net::URLFetcher& request, GURL* url); 82 static bool GetBlacklistedUrl(const net::URLFetcher& request, GURL* url);
83 83
84 // Register SuggestionsService related prefs in the Profile prefs. 84 // Register SuggestionsService related prefs in the Profile prefs.
85 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 85 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
86 86
87 base::TimeDelta blacklist_delay_for_testing() const {
88 return scheduling_delay_;
89 }
90 void set_blacklist_delay_for_testing(base::TimeDelta delay) {
91 scheduling_delay_ = delay;
92 }
93 bool has_pending_request_for_testing() const {
94 return !!pending_request_.get();
95 }
96
87 private: 97 private:
88 friend class SuggestionsServiceTest;
89 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, FetchSuggestionsData);
90 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest,
91 FetchSuggestionsDataSyncDisabled);
92 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest,
93 FetchSuggestionsDataNoAccessToken);
94 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest,
95 IssueRequestIfNoneOngoingError);
96 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest,
97 IssueRequestIfNoneOngoingResponseNotOK);
98 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, BlacklistURL);
99 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, BlacklistURLRequestFails);
100 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, ClearBlacklist);
101 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, UndoBlacklistURL);
102 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest,
103 GetBlacklistedUrlBlacklistRequest);
104 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, UpdateBlacklistDelay);
105 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, CheckDefaultTimeStamps);
106
107 // Helpers to build the various suggestions URLs. These are static members 98 // Helpers to build the various suggestions URLs. These are static members
108 // rather than local functions in the .cc file to make them accessible to 99 // rather than local functions in the .cc file to make them accessible to
109 // tests. 100 // tests.
110 static GURL BuildSuggestionsURL(); 101 static GURL BuildSuggestionsURL();
111 static std::string BuildSuggestionsBlacklistURLPrefix(); 102 static std::string BuildSuggestionsBlacklistURLPrefix();
112 static GURL BuildSuggestionsBlacklistURL(const GURL& candidate_url); 103 static GURL BuildSuggestionsBlacklistURL(const GURL& candidate_url);
113 static GURL BuildSuggestionsBlacklistClearURL(); 104 static GURL BuildSuggestionsBlacklistClearURL();
114 105
115 // syncer::SyncServiceObserver implementation. 106 // syncer::SyncServiceObserver implementation.
116 void OnStateChanged(syncer::SyncService* sync) override; 107 void OnStateChanged(syncer::SyncService* sync) override;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // If the local blacklist isn't empty, picks a URL from it and issues a 144 // If the local blacklist isn't empty, picks a URL from it and issues a
154 // blacklist request for it. 145 // blacklist request for it.
155 void UploadOneFromBlacklist(); 146 void UploadOneFromBlacklist();
156 147
157 // Updates |scheduling_delay_| based on the success of the last request. 148 // Updates |scheduling_delay_| based on the success of the last request.
158 void UpdateBlacklistDelay(bool last_request_successful); 149 void UpdateBlacklistDelay(bool last_request_successful);
159 150
160 // Adds extra data to suggestions profile. 151 // Adds extra data to suggestions profile.
161 void PopulateExtraData(SuggestionsProfile* suggestions); 152 void PopulateExtraData(SuggestionsProfile* suggestions);
162 153
163 // Test seams.
164 base::TimeDelta blacklist_delay() const { return scheduling_delay_; }
165 void set_blacklist_delay(base::TimeDelta delay) { scheduling_delay_ = delay; }
166
167 base::ThreadChecker thread_checker_; 154 base::ThreadChecker thread_checker_;
168 155
169 SigninManagerBase* signin_manager_; 156 SigninManagerBase* signin_manager_;
170 OAuth2TokenService* token_service_; 157 OAuth2TokenService* token_service_;
171 158
172 syncer::SyncService* sync_service_; 159 syncer::SyncService* sync_service_;
173 ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver> 160 ScopedObserver<syncer::SyncService, syncer::SyncServiceObserver>
174 sync_service_observer_; 161 sync_service_observer_;
175 162
176 net::URLRequestContextGetter* url_request_context_; 163 net::URLRequestContextGetter* url_request_context_;
(...skipping 27 matching lines...) Expand all
204 191
205 // For callbacks may be run after destruction. 192 // For callbacks may be run after destruction.
206 base::WeakPtrFactory<SuggestionsServiceImpl> weak_ptr_factory_; 193 base::WeakPtrFactory<SuggestionsServiceImpl> weak_ptr_factory_;
207 194
208 DISALLOW_COPY_AND_ASSIGN(SuggestionsServiceImpl); 195 DISALLOW_COPY_AND_ASSIGN(SuggestionsServiceImpl);
209 }; 196 };
210 197
211 } // namespace suggestions 198 } // namespace suggestions
212 199
213 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_IMPL_H_ 200 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698