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

Side by Side Diff: chrome/browser/search/suggestions/suggestions_service.h

Issue 299713007: [Suggestions] Adding a Thumbnail Manager for the Suggestions Service (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean Created 6 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 | Annotate | Revision Log
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 CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_
6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ 6 #define CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/search/suggestions/proto/suggestions.pb.h" 15 #include "chrome/browser/search/suggestions/proto/suggestions.pb.h"
16 #include "chrome/browser/search/suggestions/thumbnail_manager.h"
16 #include "components/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/keyed_service.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 Profile; 21 class Profile;
21 22
22 namespace suggestions { 23 namespace suggestions {
23 24
24 extern const char kSuggestionsFieldTrialName[]; 25 extern const char kSuggestionsFieldTrialName[];
25 extern const char kSuggestionsFieldTrialURLParam[]; 26 extern const char kSuggestionsFieldTrialURLParam[];
(...skipping 10 matching lines...) Expand all
36 37
37 // Whether this service is enabled. 38 // Whether this service is enabled.
38 static bool IsEnabled(); 39 static bool IsEnabled();
39 40
40 // Request suggestions data, which will be passed to |callback|. Initiates a 41 // Request suggestions data, which will be passed to |callback|. Initiates a
41 // fetch request unless a pending one exists. To prevent multiple requests, 42 // fetch request unless a pending one exists. To prevent multiple requests,
42 // we place all |callback|s in a queue and update them simultaneously when 43 // we place all |callback|s in a queue and update them simultaneously when
43 // fetch request completes. 44 // fetch request completes.
44 void FetchSuggestionsData(ResponseCallback callback); 45 void FetchSuggestionsData(ResponseCallback callback);
45 46
47 // For a given |url|, if a thumbnail URL is known for it, will start the fetch
48 // of the image and |callback|. In the case of a |url| for which the thumbnail
49 // is not known, the bitmap pointer given to the |callback| will be NULL.
50 void GetURLThumbnail(
huangs 2014/05/22 06:17:35 Suggest that you shorten this to: // Retrieves st
Mathieu 2014/05/22 15:45:51 Done.
51 const GURL& url,
52 ThumbnailManager::BitmapResponseCallback callback);
53
46 private: 54 private:
47 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, FetchSuggestionsData); 55 FRIEND_TEST_ALL_PREFIXES(SuggestionsServiceTest, FetchSuggestionsData);
48 56
49 // net::URLFetcherDelegate implementation. 57 // net::URLFetcherDelegate implementation.
50 // Called when fetch request completes. Parses the received suggestions data, 58 // Called when fetch request completes. Parses the received suggestions data,
51 // and dispatches them to callbacks stored in queue. 59 // and dispatches them to callbacks stored in queue.
52 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 60 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
53 61
54 // KeyedService implementation. 62 // KeyedService implementation.
55 virtual void Shutdown() OVERRIDE; 63 virtual void Shutdown() OVERRIDE;
56 64
57 // Contains the current suggestions fetch request. Will only have a value 65 // Contains the current suggestions fetch request. Will only have a value
58 // while a request is pending, and will be reset by |OnURLFetchComplete|. 66 // while a request is pending, and will be reset by |OnURLFetchComplete|.
59 scoped_ptr<net::URLFetcher> pending_request_; 67 scoped_ptr<net::URLFetcher> pending_request_;
60 68
61 // The start time of the previous suggestions request. This is used to measure 69 // The start time of the previous suggestions request. This is used to measure
62 // the latency of requests. Initially zero. 70 // the latency of requests. Initially zero.
63 base::TimeTicks last_request_started_time_; 71 base::TimeTicks last_request_started_time_;
64 72
65 // The URL to fetch suggestions data from. 73 // The URL to fetch suggestions data from.
66 GURL suggestions_url_; 74 GURL suggestions_url_;
67 75
68 // Queue of callbacks. These are flushed when fetch request completes. 76 // Queue of callbacks. These are flushed when fetch request completes.
69 std::vector<ResponseCallback> waiting_requestors_; 77 std::vector<ResponseCallback> waiting_requestors_;
70 78
79 // Used to obtain server thumbnails, if available.
80 scoped_ptr<ThumbnailManager> thumbnail_manager_;
81
71 Profile* profile_; 82 Profile* profile_;
72 83
73 DISALLOW_COPY_AND_ASSIGN(SuggestionsService); 84 DISALLOW_COPY_AND_ASSIGN(SuggestionsService);
74 }; 85 };
75 86
76 } // namespace suggestions 87 } // namespace suggestions
77 88
78 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_ 89 #endif // CHROME_BROWSER_SEARCH_SUGGESTIONS_SUGGESTIONS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698