OLD | NEW |
---|---|
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_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 5 #ifndef COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
6 #define COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 6 #define COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "components/keyed_service/core/keyed_service.h" | 19 #include "components/keyed_service/core/keyed_service.h" |
20 #include "components/suggestions/image_manager.h" | 20 #include "components/suggestions/image_manager.h" |
21 #include "components/suggestions/proto/suggestions.pb.h" | 21 #include "components/suggestions/proto/suggestions.pb.h" |
22 #include "components/suggestions/suggestions_utils.h" | |
22 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
23 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" |
24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
25 | 26 |
26 namespace net { | 27 namespace net { |
27 class URLRequestContextGetter; | 28 class URLRequestContextGetter; |
28 } // namespace net | 29 } // namespace net |
29 | 30 |
30 namespace user_prefs { | 31 namespace user_prefs { |
31 class PrefRegistrySyncable; | 32 class PrefRegistrySyncable; |
(...skipping 26 matching lines...) Expand all Loading... | |
58 scoped_ptr<BlacklistStore> blacklist_store); | 59 scoped_ptr<BlacklistStore> blacklist_store); |
59 virtual ~SuggestionsService(); | 60 virtual ~SuggestionsService(); |
60 | 61 |
61 // Whether this service is enabled. | 62 // Whether this service is enabled. |
62 static bool IsEnabled(); | 63 static bool IsEnabled(); |
63 | 64 |
64 // Whether the user is part of a control group. | 65 // Whether the user is part of a control group. |
65 static bool IsControlGroup(); | 66 static bool IsControlGroup(); |
66 | 67 |
67 // Request suggestions data, which will be passed to |callback|. Initiates a | 68 // Request suggestions data, which will be passed to |callback|. Initiates a |
68 // fetch request unless a pending one exists. To prevent multiple requests, | 69 // fetch request unless a pending one exists. To prevent multiple requests, |
manzagop (departed)
2014/08/20 15:43:51
I guess we shouldn't issue a request in the serve
Mathieu
2014/08/20 18:41:29
Done. Reworded comment.
| |
69 // we place all |callback|s in a queue and update them simultaneously when | 70 // we place all |callback|s in a queue and update them simultaneously when |
70 // fetch request completes. Also posts a task to execute OnRequestTimeout | 71 // fetch request completes. Also posts a task to execute OnRequestTimeout |
71 // if the request hasn't completed in a given amount of time. | 72 // if the request hasn't completed in a given amount of time. |sync_state| |
72 void FetchSuggestionsData(ResponseCallback callback); | 73 // must be specified based on the current state of the system (see |
74 // suggestions::GetSyncState). Callers should call this function again if | |
75 // sync state changes. | |
76 void FetchSuggestionsData(SyncState sync_state, | |
77 ResponseCallback callback); | |
73 | 78 |
74 // Similar to FetchSuggestionsData but doesn't post a task to execute | 79 // Similar to FetchSuggestionsData but doesn't post a task to execute |
75 // OnDelaySinceFetch. | 80 // OnDelaySinceFetch. |
76 void FetchSuggestionsDataNoTimeout(ResponseCallback callback); | 81 void FetchSuggestionsDataNoTimeout(ResponseCallback callback); |
77 | 82 |
78 // Retrieves stored thumbnail for website |url| asynchronously. Calls | 83 // Retrieves stored thumbnail for website |url| asynchronously. Calls |
79 // |callback| with Bitmap pointer if found, and NULL otherwise. | 84 // |callback| with Bitmap pointer if found, and NULL otherwise. |
80 void GetPageThumbnail( | 85 void GetPageThumbnail( |
81 const GURL& url, | 86 const GURL& url, |
82 base::Callback<void(const GURL&, const SkBitmap*)> callback); | 87 base::Callback<void(const GURL&, const SkBitmap*)> callback); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 // Timeout (in ms) before serving requestors after a fetch suggestions request | 189 // Timeout (in ms) before serving requestors after a fetch suggestions request |
185 // has been issued. | 190 // has been issued. |
186 int request_timeout_ms_; | 191 int request_timeout_ms_; |
187 | 192 |
188 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); | 193 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); |
189 }; | 194 }; |
190 | 195 |
191 } // namespace suggestions | 196 } // namespace suggestions |
192 | 197 |
193 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ | 198 #endif // COMPONENTS_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ |
OLD | NEW |