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

Side by Side Diff: chrome/browser/history/web_history_service.h

Issue 889553003: Revert of Componentize WebHistoryService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mon Feb 2 15:10:48 PST 2015 Created 5 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_HISTORY_CORE_BROWSER_WEB_HISTORY_SERVICE_H_ 5 #ifndef CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_
6 #define COMPONENTS_HISTORY_CORE_BROWSER_WEB_HISTORY_SERVICE_H_ 6 #define CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string>
10 #include <vector>
11 9
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/profiles/profile.h"
14 #include "components/history/core/browser/history_types.h" 12 #include "components/history/core/browser/history_types.h"
15 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
16 14
17 namespace base { 15 namespace base {
18 class DictionaryValue; 16 class DictionaryValue;
19 } 17 }
20 18
21 namespace net { 19 namespace net {
22 class URLRequestContextGetter; 20 class URLFetcher;
23 } 21 }
24 22
25 class OAuth2TokenService;
26 class SigninManagerBase;
27
28 namespace history { 23 namespace history {
29 24
30 // Provides an API for querying Google servers for a signed-in user's 25 // Provides an API for querying Google servers for a signed-in user's
31 // synced history visits. It is roughly analogous to HistoryService, and 26 // synced history visits. It is roughly analogous to HistoryService, and
32 // supports a similar API. 27 // supports a similar API.
33 class WebHistoryService : public KeyedService { 28 class WebHistoryService : public KeyedService {
34 public: 29 public:
35 // Handles all the work of making an API request. This class encapsulates 30 // Handles all the work of making an API request. This class encapsulates
36 // the entire state of the request. When an instance is destroyed, all 31 // the entire state of the request. When an instance is destroyed, all
37 // aspects of the request are cancelled. 32 // aspects of the request are cancelled.
(...skipping 27 matching lines...) Expand all
65 typedef base::Callback<void(Request*, const base::DictionaryValue*)> 60 typedef base::Callback<void(Request*, const base::DictionaryValue*)>
66 QueryWebHistoryCallback; 61 QueryWebHistoryCallback;
67 62
68 typedef base::Callback<void(bool success)> ExpireWebHistoryCallback; 63 typedef base::Callback<void(bool success)> ExpireWebHistoryCallback;
69 64
70 typedef base::Callback<void(bool success, bool new_enabled_value)> 65 typedef base::Callback<void(bool success, bool new_enabled_value)>
71 AudioWebHistoryCallback; 66 AudioWebHistoryCallback;
72 67
73 typedef base::Callback<void(Request*, bool success)> CompletionCallback; 68 typedef base::Callback<void(Request*, bool success)> CompletionCallback;
74 69
75 WebHistoryService( 70 explicit WebHistoryService(Profile* profile);
76 OAuth2TokenService* token_service,
77 SigninManagerBase* signin_manager,
78 const scoped_refptr<net::URLRequestContextGetter>& request_context);
79 ~WebHistoryService() override; 71 ~WebHistoryService() override;
80 72
81 // Searches synced history for visits matching |text_query|. The timeframe to 73 // Searches synced history for visits matching |text_query|. The timeframe to
82 // search, along with other options, is specified in |options|. If 74 // search, along with other options, is specified in |options|. If
83 // |text_query| is empty, all visits in the timeframe will be returned. 75 // |text_query| is empty, all visits in the timeframe will be returned.
84 // This method is the equivalent of HistoryService::QueryHistory. 76 // This method is the equivalent of HistoryService::QueryHistory.
85 // The caller takes ownership of the returned Request. If it is destroyed, the 77 // The caller takes ownership of the returned Request. If it is destroyed, the
86 // request is cancelled. 78 // request is cancelled.
87 scoped_ptr<Request> QueryHistory( 79 scoped_ptr<Request> QueryHistory(
88 const base::string16& text_query, 80 const base::string16& text_query,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // server has completed. Unpacks the response and calls |callback|, which is 134 // server has completed. Unpacks the response and calls |callback|, which is
143 // the original callback that was passed to AudioHistory(). 135 // the original callback that was passed to AudioHistory().
144 void AudioHistoryCompletionCallback( 136 void AudioHistoryCompletionCallback(
145 const WebHistoryService::AudioWebHistoryCallback& callback, 137 const WebHistoryService::AudioWebHistoryCallback& callback,
146 WebHistoryService::Request* request, 138 WebHistoryService::Request* request,
147 bool success); 139 bool success);
148 140
149 private: 141 private:
150 friend class WebHistoryServiceTest; 142 friend class WebHistoryServiceTest;
151 143
152 // Stores pointer to OAuth2TokenService and SigninManagerBase instance. They 144 Profile* profile_;
153 // must outlive the WebHistoryService and can be null during tests.
154 OAuth2TokenService* token_service_;
155 SigninManagerBase* signin_manager_;
156
157 // Request context getter to use.
158 scoped_refptr<net::URLRequestContextGetter> request_context_;
159 145
160 // Stores the version_info token received from the server in response to 146 // Stores the version_info token received from the server in response to
161 // a mutation operation (e.g., deleting history). This is used to ensure that 147 // a mutation operation (e.g., deleting history). This is used to ensure that
162 // subsequent reads see a version of the data that includes the mutation. 148 // subsequent reads see a version of the data that includes the mutation.
163 std::string server_version_info_; 149 std::string server_version_info_;
164 150
165 // Pending expiration requests to be canceled if not complete by profile 151 // Pending expiration requests to be canceled if not complete by profile
166 // shutdown. 152 // shutdown.
167 std::set<Request*> pending_expire_requests_; 153 std::set<Request*> pending_expire_requests_;
168 154
169 // Pending requests to be canceled if not complete by profile shutdown. 155 // Pending requests to be canceled if not complete by profile shutdown.
170 std::set<Request*> pending_audio_history_requests_; 156 std::set<Request*> pending_audio_history_requests_;
171 157
172 base::WeakPtrFactory<WebHistoryService> weak_ptr_factory_; 158 base::WeakPtrFactory<WebHistoryService> weak_ptr_factory_;
173 159
174 DISALLOW_COPY_AND_ASSIGN(WebHistoryService); 160 DISALLOW_COPY_AND_ASSIGN(WebHistoryService);
175 }; 161 };
176 162
177 } // namespace history 163 } // namespace history
178 164
179 #endif // COMPONENTS_HISTORY_CORE_BROWSER_WEB_HISTORY_SERVICE_H_ 165 #endif // CHROME_BROWSER_HISTORY_WEB_HISTORY_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/history_service.cc ('k') | chrome/browser/history/web_history_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698