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

Side by Side Diff: components/ntp_snippets/remote/remote_suggestions_provider.h

Issue 2569663004: [NTPSnippets] Switch from TickClock to Clock for storing the last background fetched time. (Closed)
Patch Set: Add a DCHECK to check that the num or args passed to the new method is 0 Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_PROVIDER_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_PROVIDER_H_
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_PROVIDER_H_ 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_PROVIDER_H_
7 7
8 #include <cstddef> 8 #include <cstddef>
9 #include <deque> 9 #include <deque>
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback_forward.h" 16 #include "base/callback_forward.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/time/clock.h"
19 #include "base/time/time.h" 20 #include "base/time/time.h"
20 #include "components/image_fetcher/image_fetcher_delegate.h" 21 #include "components/image_fetcher/image_fetcher_delegate.h"
21 #include "components/ntp_snippets/category.h" 22 #include "components/ntp_snippets/category.h"
22 #include "components/ntp_snippets/category_factory.h" 23 #include "components/ntp_snippets/category_factory.h"
23 #include "components/ntp_snippets/category_status.h" 24 #include "components/ntp_snippets/category_status.h"
24 #include "components/ntp_snippets/content_suggestion.h" 25 #include "components/ntp_snippets/content_suggestion.h"
25 #include "components/ntp_snippets/content_suggestions_provider.h" 26 #include "components/ntp_snippets/content_suggestions_provider.h"
26 #include "components/ntp_snippets/remote/ntp_snippet.h" 27 #include "components/ntp_snippets/remote/ntp_snippet.h"
27 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h" 28 #include "components/ntp_snippets/remote/ntp_snippets_fetcher.h"
28 #include "components/ntp_snippets/remote/ntp_snippets_scheduler.h" 29 #include "components/ntp_snippets/remote/ntp_snippets_scheduler.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return category_contents_.find(category)->second.snippets; 146 return category_contents_.find(category)->second.snippets;
146 } 147 }
147 148
148 // Dismissed snippets, only for unit tests. 149 // Dismissed snippets, only for unit tests.
149 const NTPSnippet::PtrVector& GetDismissedSnippetsForTesting( 150 const NTPSnippet::PtrVector& GetDismissedSnippetsForTesting(
150 Category category) const { 151 Category category) const {
151 return category_contents_.find(category)->second.dismissed; 152 return category_contents_.find(category)->second.dismissed;
152 } 153 }
153 154
154 // Overrides internal clock for testing purposes. 155 // Overrides internal clock for testing purposes.
155 void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock) { 156 void SetClockForTesting(std::unique_ptr<base::Clock> clock) {
156 tick_clock_ = std::move(tick_clock); 157 clock_ = std::move(clock);
157 } 158 }
158 159
159 private: 160 private:
160 friend class RemoteSuggestionsProviderTest; 161 friend class RemoteSuggestionsProviderTest;
161 162
162 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsProviderTest, 163 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsProviderTest,
163 DontNotifyIfNotAvailable); 164 DontNotifyIfNotAvailable);
164 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsProviderTest, 165 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsProviderTest,
165 RemoveExpiredDismissedContent); 166 RemoveExpiredDismissedContent);
166 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsProviderTest, 167 FRIEND_TEST_ALL_PREFIXES(RemoteSuggestionsProviderTest,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 bool fetch_when_ready_; 409 bool fetch_when_ready_;
409 410
410 // Set to true if NukeAllSnippets is called while the service isn't ready. 411 // Set to true if NukeAllSnippets is called while the service isn't ready.
411 // The nuke will be executed once the service finishes initialization or 412 // The nuke will be executed once the service finishes initialization or
412 // enters the READY state. 413 // enters the READY state.
413 bool nuke_when_initialized_; 414 bool nuke_when_initialized_;
414 415
415 // Request throttler for limiting requests to thumbnail images. 416 // Request throttler for limiting requests to thumbnail images.
416 RequestThrottler thumbnail_requests_throttler_; 417 RequestThrottler thumbnail_requests_throttler_;
417 418
418 // A clock for getting the time. This allows to inject a tick clock in tests. 419 // A clock for getting the time. This allows to inject a clock in tests.
419 std::unique_ptr<base::TickClock> tick_clock_; 420 std::unique_ptr<base::Clock> clock_;
420 421
421 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsProvider); 422 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsProvider);
422 }; 423 };
423 424
424 } // namespace ntp_snippets 425 } // namespace ntp_snippets
425 426
426 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_PROVIDER_H_ 427 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/snippets_internals_ui.cc ('k') | components/ntp_snippets/remote/remote_suggestions_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698