OLD | NEW |
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 #include "chrome/browser/chromeos/drive/drive_api_service.h" | 5 #include "chrome/browser/google_apis/drive_api_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/google_apis/drive_api_operations.h" | 15 #include "chrome/browser/google_apis/drive_api_operations.h" |
16 #include "chrome/browser/google_apis/drive_api_parser.h" | 16 #include "chrome/browser/google_apis/drive_api_parser.h" |
17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
18 #include "chrome/browser/google_apis/operation_runner.h" | 18 #include "chrome/browser/google_apis/operation_runner.h" |
19 #include "chrome/browser/google_apis/time_util.h" | 19 #include "chrome/browser/google_apis/time_util.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/common/net/url_util.h" | 21 #include "chrome/common/net/url_util.h" |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
23 | 23 |
24 using content::BrowserThread; | 24 using content::BrowserThread; |
25 | 25 |
26 namespace drive { | 26 namespace google_apis { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // OAuth2 scopes for Drive API. | 30 // OAuth2 scopes for Drive API. |
31 const char kDriveScope[] = "https://www.googleapis.com/auth/drive"; | 31 const char kDriveScope[] = "https://www.googleapis.com/auth/drive"; |
32 const char kDriveAppsReadonlyScope[] = | 32 const char kDriveAppsReadonlyScope[] = |
33 "https://www.googleapis.com/auth/drive.apps.readonly"; | 33 "https://www.googleapis.com/auth/drive.apps.readonly"; |
34 | 34 |
35 scoped_ptr<google_apis::ResourceList> ParseResourceListOnBlockingPool( | 35 scoped_ptr<ResourceList> ParseResourceListOnBlockingPool( |
36 scoped_ptr<base::Value> value, google_apis::GDataErrorCode* error) { | 36 scoped_ptr<base::Value> value, GDataErrorCode* error) { |
37 if (!value) { | 37 if (!value) { |
38 // JSON value is not available. | 38 // JSON value is not available. |
39 return scoped_ptr<google_apis::ResourceList>(); | 39 return scoped_ptr<ResourceList>(); |
40 } | 40 } |
41 | 41 |
42 // Parse the value into ResourceList via ChangeList. | 42 // Parse the value into ResourceList via ChangeList. |
43 // If failed, set (i.e. overwrite) the error flag and return immediately. | 43 // If failed, set (i.e. overwrite) the error flag and return immediately. |
44 scoped_ptr<google_apis::ChangeList> change_list( | 44 scoped_ptr<ChangeList> change_list(ChangeList::CreateFrom(*value)); |
45 google_apis::ChangeList::CreateFrom(*value)); | |
46 if (!change_list) { | 45 if (!change_list) { |
47 *error = google_apis::GDATA_PARSE_ERROR; | 46 *error = GDATA_PARSE_ERROR; |
48 return scoped_ptr<google_apis::ResourceList>(); | 47 return scoped_ptr<ResourceList>(); |
49 } | 48 } |
50 | 49 |
51 scoped_ptr<google_apis::ResourceList> resource_list = | 50 scoped_ptr<ResourceList> resource_list = |
52 google_apis::ResourceList::CreateFromChangeList(*change_list); | 51 ResourceList::CreateFromChangeList(*change_list); |
53 if (!resource_list) { | 52 if (!resource_list) { |
54 *error = google_apis::GDATA_PARSE_ERROR; | 53 *error = GDATA_PARSE_ERROR; |
55 return scoped_ptr<google_apis::ResourceList>(); | 54 return scoped_ptr<ResourceList>(); |
56 } | 55 } |
57 | 56 |
58 // Pass the result to the params, so that DidParseResourceListOnBlockingPool | 57 // Pass the result to the params, so that DidParseResourceListOnBlockingPool |
59 // defined below can process it. | 58 // defined below can process it. |
60 return resource_list.Pass(); | 59 return resource_list.Pass(); |
61 } | 60 } |
62 | 61 |
63 // Callback invoked when the parsing of resource list is completed, | 62 // Callback invoked when the parsing of resource list is completed, |
64 // regardless whether it is succeeded or not. | 63 // regardless whether it is succeeded or not. |
65 void DidParseResourceListOnBlockingPool( | 64 void DidParseResourceListOnBlockingPool( |
66 const google_apis::GetResourceListCallback& callback, | 65 const GetResourceListCallback& callback, |
67 google_apis::GDataErrorCode* error, | 66 GDataErrorCode* error, |
68 scoped_ptr<google_apis::ResourceList> resource_list) { | 67 scoped_ptr<ResourceList> resource_list) { |
69 callback.Run(*error, resource_list.Pass()); | 68 callback.Run(*error, resource_list.Pass()); |
70 } | 69 } |
71 | 70 |
72 // Sends a task to parse the JSON value into ResourceList on blocking pool, | 71 // Sends a task to parse the JSON value into ResourceList on blocking pool, |
73 // with a callback which is called when the task is done. | 72 // with a callback which is called when the task is done. |
74 void ParseResourceListOnBlockingPoolAndRun( | 73 void ParseResourceListOnBlockingPoolAndRun( |
75 const google_apis::GetResourceListCallback& callback, | 74 const GetResourceListCallback& callback, |
76 google_apis::GDataErrorCode in_error, | 75 GDataErrorCode in_error, |
77 scoped_ptr<base::Value> value) { | 76 scoped_ptr<base::Value> value) { |
78 // Note that the error value may be overwritten in | 77 // Note that the error value may be overwritten in |
79 // ParseResoruceListOnBlockingPool before used in | 78 // ParseResoruceListOnBlockingPool before used in |
80 // DidParseResourceListOnBlockingPool. | 79 // DidParseResourceListOnBlockingPool. |
81 google_apis::GDataErrorCode* error = | 80 GDataErrorCode* error = new GDataErrorCode(in_error); |
82 new google_apis::GDataErrorCode(in_error); | |
83 | 81 |
84 PostTaskAndReplyWithResult( | 82 PostTaskAndReplyWithResult( |
85 BrowserThread::GetBlockingPool(), | 83 BrowserThread::GetBlockingPool(), |
86 FROM_HERE, | 84 FROM_HERE, |
87 base::Bind(&ParseResourceListOnBlockingPool, | 85 base::Bind(&ParseResourceListOnBlockingPool, |
88 base::Passed(&value), error), | 86 base::Passed(&value), error), |
89 base::Bind(&DidParseResourceListOnBlockingPool, | 87 base::Bind(&DidParseResourceListOnBlockingPool, |
90 callback, base::Owned(error))); | 88 callback, base::Owned(error))); |
91 } | 89 } |
92 | 90 |
93 // Parses the JSON value to ResourceEntry runs |callback|. | 91 // Parses the JSON value to ResourceEntry runs |callback|. |
94 void ParseResourceEntryAndRun( | 92 void ParseResourceEntryAndRun( |
95 const google_apis::GetResourceEntryCallback& callback, | 93 const GetResourceEntryCallback& callback, |
96 google_apis::GDataErrorCode error, | 94 GDataErrorCode error, |
97 scoped_ptr<base::Value> value) { | 95 scoped_ptr<base::Value> value) { |
98 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 96 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
99 | 97 |
100 if (!value) { | 98 if (!value) { |
101 callback.Run(error, scoped_ptr<google_apis::ResourceEntry>()); | 99 callback.Run(error, scoped_ptr<ResourceEntry>()); |
102 return; | 100 return; |
103 } | 101 } |
104 | 102 |
105 // Parsing FileResource is cheap enough to do on UI thread. | 103 // Parsing FileResource is cheap enough to do on UI thread. |
106 scoped_ptr<google_apis::FileResource> file_resource = | 104 scoped_ptr<FileResource> file_resource = FileResource::CreateFrom(*value); |
107 google_apis::FileResource::CreateFrom(*value); | |
108 if (!file_resource) { | 105 if (!file_resource) { |
109 callback.Run(google_apis::GDATA_PARSE_ERROR, | 106 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>()); |
110 scoped_ptr<google_apis::ResourceEntry>()); | |
111 return; | 107 return; |
112 } | 108 } |
113 | 109 |
114 // Converting to ResourceEntry is cheap enough to do on UI thread. | 110 // Converting to ResourceEntry is cheap enough to do on UI thread. |
115 scoped_ptr<google_apis::ResourceEntry> entry = | 111 scoped_ptr<ResourceEntry> entry = |
116 google_apis::ResourceEntry::CreateFromFileResource(*file_resource); | 112 ResourceEntry::CreateFromFileResource(*file_resource); |
117 if (!entry) { | 113 if (!entry) { |
118 callback.Run(google_apis::GDATA_PARSE_ERROR, | 114 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<ResourceEntry>()); |
119 scoped_ptr<google_apis::ResourceEntry>()); | |
120 return; | 115 return; |
121 } | 116 } |
122 | 117 |
123 callback.Run(error, entry.Pass()); | 118 callback.Run(error, entry.Pass()); |
124 } | 119 } |
125 | 120 |
126 // Parses the JSON value to AccountMetadataFeed on the blocking pool and runs | 121 // Parses the JSON value to AccountMetadataFeed on the blocking pool and runs |
127 // |callback| on the UI thread once parsing is done. | 122 // |callback| on the UI thread once parsing is done. |
128 void ParseAccounetMetadataAndRun( | 123 void ParseAccounetMetadataAndRun( |
129 const google_apis::GetAccountMetadataCallback& callback, | 124 const GetAccountMetadataCallback& callback, |
130 google_apis::GDataErrorCode error, | 125 GDataErrorCode error, |
131 scoped_ptr<base::Value> value) { | 126 scoped_ptr<base::Value> value) { |
132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
133 DCHECK(!callback.is_null()); | 128 DCHECK(!callback.is_null()); |
134 | 129 |
135 if (!value) { | 130 if (!value) { |
136 callback.Run(error, scoped_ptr<google_apis::AccountMetadataFeed>()); | 131 callback.Run(error, scoped_ptr<AccountMetadataFeed>()); |
137 return; | 132 return; |
138 } | 133 } |
139 | 134 |
140 // Parsing AboutResource is cheap enough to do on UI thread. | 135 // Parsing AboutResource is cheap enough to do on UI thread. |
141 scoped_ptr<google_apis::AboutResource> about_resource = | 136 scoped_ptr<AboutResource> about_resource = AboutResource::CreateFrom(*value); |
142 google_apis::AboutResource::CreateFrom(*value); | |
143 | 137 |
144 // TODO(satorux): Convert AboutResource to AccountMetadataFeed. | 138 // TODO(satorux): Convert AboutResource to AccountMetadataFeed. |
145 // For now just returning an error. crbug.com/165621 | 139 // For now just returning an error. crbug.com/165621 |
146 callback.Run(google_apis::GDATA_PARSE_ERROR, | 140 callback.Run(GDATA_PARSE_ERROR, scoped_ptr<AccountMetadataFeed>()); |
147 scoped_ptr<google_apis::AccountMetadataFeed>()); | |
148 } | 141 } |
149 | 142 |
150 } // namespace | 143 } // namespace |
151 | 144 |
152 DriveAPIService::DriveAPIService( | 145 DriveAPIService::DriveAPIService( |
153 net::URLRequestContextGetter* url_request_context_getter, | 146 net::URLRequestContextGetter* url_request_context_getter, |
154 const GURL& base_url, | 147 const GURL& base_url, |
155 const std::string& custom_user_agent) | 148 const std::string& custom_user_agent) |
156 : url_request_context_getter_(url_request_context_getter), | 149 : url_request_context_getter_(url_request_context_getter), |
157 profile_(NULL), | 150 profile_(NULL), |
(...skipping 11 matching lines...) Expand all Loading... |
169 } | 162 } |
170 } | 163 } |
171 | 164 |
172 void DriveAPIService::Initialize(Profile* profile) { | 165 void DriveAPIService::Initialize(Profile* profile) { |
173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
174 profile_ = profile; | 167 profile_ = profile; |
175 | 168 |
176 std::vector<std::string> scopes; | 169 std::vector<std::string> scopes; |
177 scopes.push_back(kDriveScope); | 170 scopes.push_back(kDriveScope); |
178 scopes.push_back(kDriveAppsReadonlyScope); | 171 scopes.push_back(kDriveAppsReadonlyScope); |
179 runner_.reset( | 172 runner_.reset(new OperationRunner(profile, |
180 new google_apis::OperationRunner(profile, | 173 url_request_context_getter_, |
181 url_request_context_getter_, | 174 scopes, |
182 scopes, | 175 custom_user_agent_)); |
183 custom_user_agent_)); | |
184 runner_->Initialize(); | 176 runner_->Initialize(); |
185 | 177 |
186 runner_->auth_service()->AddObserver(this); | 178 runner_->auth_service()->AddObserver(this); |
187 runner_->operation_registry()->AddObserver(this); | 179 runner_->operation_registry()->AddObserver(this); |
188 } | 180 } |
189 | 181 |
190 void DriveAPIService::AddObserver(google_apis::DriveServiceObserver* observer) { | 182 void DriveAPIService::AddObserver(DriveServiceObserver* observer) { |
191 observers_.AddObserver(observer); | 183 observers_.AddObserver(observer); |
192 } | 184 } |
193 | 185 |
194 void DriveAPIService::RemoveObserver( | 186 void DriveAPIService::RemoveObserver(DriveServiceObserver* observer) { |
195 google_apis::DriveServiceObserver* observer) { | |
196 observers_.RemoveObserver(observer); | 187 observers_.RemoveObserver(observer); |
197 } | 188 } |
198 | 189 |
199 bool DriveAPIService::CanStartOperation() const { | 190 bool DriveAPIService::CanStartOperation() const { |
200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
201 | 192 |
202 return HasRefreshToken(); | 193 return HasRefreshToken(); |
203 } | 194 } |
204 | 195 |
205 void DriveAPIService::CancelAll() { | 196 void DriveAPIService::CancelAll() { |
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
207 runner_->CancelAll(); | 198 runner_->CancelAll(); |
208 } | 199 } |
209 | 200 |
210 bool DriveAPIService::CancelForFilePath(const FilePath& file_path) { | 201 bool DriveAPIService::CancelForFilePath(const FilePath& file_path) { |
211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
212 return operation_registry()->CancelForFilePath(file_path); | 203 return operation_registry()->CancelForFilePath(file_path); |
213 } | 204 } |
214 | 205 |
215 google_apis::OperationProgressStatusList | 206 OperationProgressStatusList DriveAPIService::GetProgressStatusList() const { |
216 DriveAPIService::GetProgressStatusList() const { | |
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
218 return operation_registry()->GetProgressStatusList(); | 208 return operation_registry()->GetProgressStatusList(); |
219 } | 209 } |
220 | 210 |
221 void DriveAPIService::GetResourceList( | 211 void DriveAPIService::GetResourceList( |
222 const GURL& url, | 212 const GURL& url, |
223 int64 start_changestamp, | 213 int64 start_changestamp, |
224 const std::string& search_query, | 214 const std::string& search_query, |
225 bool shared_with_me, | 215 bool shared_with_me, |
226 const std::string& directory_resource_id, | 216 const std::string& directory_resource_id, |
227 const google_apis::GetResourceListCallback& callback) { | 217 const GetResourceListCallback& callback) { |
228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
229 DCHECK(!callback.is_null()); | 219 DCHECK(!callback.is_null()); |
230 | 220 |
231 if (search_query.empty()) | 221 if (search_query.empty()) |
232 GetChangelist(url, start_changestamp, callback); | 222 GetChangelist(url, start_changestamp, callback); |
233 else | 223 else |
234 GetFilelist(url, search_query, callback); | 224 GetFilelist(url, search_query, callback); |
235 | 225 |
236 return; | 226 return; |
237 // TODO(kochi): Implement !directory_resource_id.empty() case. | 227 // TODO(kochi): Implement !directory_resource_id.empty() case. |
238 NOTREACHED(); | 228 NOTREACHED(); |
239 } | 229 } |
240 | 230 |
241 void DriveAPIService::GetFilelist( | 231 void DriveAPIService::GetFilelist( |
242 const GURL& url, | 232 const GURL& url, |
243 const std::string& search_query, | 233 const std::string& search_query, |
244 const google_apis::GetResourceListCallback& callback) { | 234 const GetResourceListCallback& callback) { |
245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
246 DCHECK(!callback.is_null()); | 236 DCHECK(!callback.is_null()); |
247 | 237 |
248 runner_->StartOperationWithRetry( | 238 runner_->StartOperationWithRetry( |
249 new google_apis::GetFilelistOperation( | 239 new GetFilelistOperation( |
250 operation_registry(), | 240 operation_registry(), |
251 url_request_context_getter_, | 241 url_request_context_getter_, |
252 url_generator_, | 242 url_generator_, |
253 url, | 243 url, |
254 search_query, | 244 search_query, |
255 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); | 245 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); |
256 } | 246 } |
257 | 247 |
258 void DriveAPIService::GetChangelist( | 248 void DriveAPIService::GetChangelist( |
259 const GURL& url, | 249 const GURL& url, |
260 int64 start_changestamp, | 250 int64 start_changestamp, |
261 const google_apis::GetResourceListCallback& callback) { | 251 const GetResourceListCallback& callback) { |
262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
263 DCHECK(!callback.is_null()); | 253 DCHECK(!callback.is_null()); |
264 | 254 |
265 runner_->StartOperationWithRetry( | 255 runner_->StartOperationWithRetry( |
266 new google_apis::GetChangelistOperation( | 256 new GetChangelistOperation( |
267 operation_registry(), | 257 operation_registry(), |
268 url_request_context_getter_, | 258 url_request_context_getter_, |
269 url_generator_, | 259 url_generator_, |
270 url, | 260 url, |
271 start_changestamp, | 261 start_changestamp, |
272 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); | 262 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); |
273 } | 263 } |
274 | 264 |
275 void DriveAPIService::GetResourceEntry( | 265 void DriveAPIService::GetResourceEntry( |
276 const std::string& resource_id, | 266 const std::string& resource_id, |
277 const google_apis::GetResourceEntryCallback& callback) { | 267 const GetResourceEntryCallback& callback) { |
278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
279 DCHECK(!callback.is_null()); | 269 DCHECK(!callback.is_null()); |
280 | 270 |
281 runner_->StartOperationWithRetry(new google_apis::GetFileOperation( | 271 runner_->StartOperationWithRetry(new GetFileOperation( |
282 operation_registry(), | 272 operation_registry(), |
283 url_request_context_getter_, | 273 url_request_context_getter_, |
284 url_generator_, | 274 url_generator_, |
285 resource_id, | 275 resource_id, |
286 base::Bind(&ParseResourceEntryAndRun, callback))); | 276 base::Bind(&ParseResourceEntryAndRun, callback))); |
287 } | 277 } |
288 | 278 |
289 void DriveAPIService::GetAccountMetadata( | 279 void DriveAPIService::GetAccountMetadata( |
290 const google_apis::GetAccountMetadataCallback& callback) { | 280 const GetAccountMetadataCallback& callback) { |
291 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
292 DCHECK(!callback.is_null()); | 282 DCHECK(!callback.is_null()); |
293 | 283 |
294 runner_->StartOperationWithRetry( | 284 runner_->StartOperationWithRetry( |
295 new google_apis::GetAboutOperation( | 285 new GetAboutOperation( |
296 operation_registry(), | 286 operation_registry(), |
297 url_request_context_getter_, | 287 url_request_context_getter_, |
298 url_generator_, | 288 url_generator_, |
299 base::Bind(&ParseAccounetMetadataAndRun, callback))); | 289 base::Bind(&ParseAccounetMetadataAndRun, callback))); |
300 } | 290 } |
301 | 291 |
302 void DriveAPIService::GetApplicationInfo( | 292 void DriveAPIService::GetApplicationInfo(const GetDataCallback& callback) { |
303 const google_apis::GetDataCallback& callback) { | |
304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
305 DCHECK(!callback.is_null()); | 294 DCHECK(!callback.is_null()); |
306 | 295 |
307 runner_->StartOperationWithRetry( | 296 runner_->StartOperationWithRetry(new GetApplistOperation( |
308 new google_apis::GetApplistOperation(operation_registry(), | 297 operation_registry(), |
309 url_request_context_getter_, | 298 url_request_context_getter_, |
310 url_generator_, | 299 url_generator_, |
311 callback)); | 300 callback)); |
312 } | 301 } |
313 | 302 |
314 void DriveAPIService::DownloadHostedDocument( | 303 void DriveAPIService::DownloadHostedDocument( |
315 const FilePath& virtual_path, | 304 const FilePath& virtual_path, |
316 const FilePath& local_cache_path, | 305 const FilePath& local_cache_path, |
317 const GURL& content_url, | 306 const GURL& content_url, |
318 google_apis::DocumentExportFormat format, | 307 DocumentExportFormat format, |
319 const google_apis::DownloadActionCallback& callback) { | 308 const DownloadActionCallback& callback) { |
320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 309 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
321 DCHECK(!callback.is_null()); | 310 DCHECK(!callback.is_null()); |
322 | 311 |
323 // TODO(kochi): Implement this. | 312 // TODO(kochi): Implement this. |
324 NOTREACHED(); | 313 NOTREACHED(); |
325 } | 314 } |
326 | 315 |
327 void DriveAPIService::DownloadFile( | 316 void DriveAPIService::DownloadFile( |
328 const FilePath& virtual_path, | 317 const FilePath& virtual_path, |
329 const FilePath& local_cache_path, | 318 const FilePath& local_cache_path, |
330 const GURL& content_url, | 319 const GURL& content_url, |
331 const google_apis::DownloadActionCallback& download_action_callback, | 320 const DownloadActionCallback& download_action_callback, |
332 const google_apis::GetContentCallback& get_content_callback) { | 321 const GetContentCallback& get_content_callback) { |
333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 322 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
334 DCHECK(!download_action_callback.is_null()); | 323 DCHECK(!download_action_callback.is_null()); |
335 // get_content_callback may be null. | 324 // get_content_callback may be null. |
336 | 325 |
337 // TODO(kochi): Implement this. | 326 // TODO(kochi): Implement this. |
338 NOTREACHED(); | 327 NOTREACHED(); |
339 } | 328 } |
340 | 329 |
341 void DriveAPIService::DeleteResource( | 330 void DriveAPIService::DeleteResource( |
342 const GURL& edit_url, | 331 const GURL& edit_url, |
343 const google_apis::EntryActionCallback& callback) { | 332 const EntryActionCallback& callback) { |
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
345 DCHECK(!callback.is_null()); | 334 DCHECK(!callback.is_null()); |
346 | 335 |
347 // TODO(kochi): Implement this. | 336 // TODO(kochi): Implement this. |
348 NOTREACHED(); | 337 NOTREACHED(); |
349 } | 338 } |
350 | 339 |
351 void DriveAPIService::AddNewDirectory( | 340 void DriveAPIService::AddNewDirectory( |
352 const GURL& parent_content_url, | 341 const GURL& parent_content_url, |
353 const FilePath::StringType& directory_name, | 342 const FilePath::StringType& directory_name, |
354 const google_apis::GetResourceEntryCallback& callback) { | 343 const GetResourceEntryCallback& callback) { |
355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
356 DCHECK(!callback.is_null()); | 345 DCHECK(!callback.is_null()); |
357 | 346 |
358 // TODO(kochi): Implement this. | 347 // TODO(kochi): Implement this. |
359 NOTREACHED(); | 348 NOTREACHED(); |
360 } | 349 } |
361 | 350 |
362 void DriveAPIService::CopyHostedDocument( | 351 void DriveAPIService::CopyHostedDocument( |
363 const std::string& resource_id, | 352 const std::string& resource_id, |
364 const FilePath::StringType& new_name, | 353 const FilePath::StringType& new_name, |
365 const google_apis::GetResourceEntryCallback& callback) { | 354 const GetResourceEntryCallback& callback) { |
366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 355 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
367 DCHECK(!callback.is_null()); | 356 DCHECK(!callback.is_null()); |
368 | 357 |
369 // TODO(kochi): Implement this. | 358 // TODO(kochi): Implement this. |
370 NOTREACHED(); | 359 NOTREACHED(); |
371 } | 360 } |
372 | 361 |
373 void DriveAPIService::RenameResource( | 362 void DriveAPIService::RenameResource( |
374 const GURL& edit_url, | 363 const GURL& edit_url, |
375 const FilePath::StringType& new_name, | 364 const FilePath::StringType& new_name, |
376 const google_apis::EntryActionCallback& callback) { | 365 const EntryActionCallback& callback) { |
377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
378 DCHECK(!callback.is_null()); | 367 DCHECK(!callback.is_null()); |
379 | 368 |
380 // TODO(kochi): Implement this. | 369 // TODO(kochi): Implement this. |
381 NOTREACHED(); | 370 NOTREACHED(); |
382 } | 371 } |
383 | 372 |
384 void DriveAPIService::AddResourceToDirectory( | 373 void DriveAPIService::AddResourceToDirectory( |
385 const GURL& parent_content_url, | 374 const GURL& parent_content_url, |
386 const GURL& edit_url, | 375 const GURL& edit_url, |
387 const google_apis::EntryActionCallback& callback) { | 376 const EntryActionCallback& callback) { |
388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
389 DCHECK(!callback.is_null()); | 378 DCHECK(!callback.is_null()); |
390 | 379 |
391 // TODO(kochi): Implement this. | 380 // TODO(kochi): Implement this. |
392 NOTREACHED(); | 381 NOTREACHED(); |
393 } | 382 } |
394 | 383 |
395 void DriveAPIService::RemoveResourceFromDirectory( | 384 void DriveAPIService::RemoveResourceFromDirectory( |
396 const GURL& parent_content_url, | 385 const GURL& parent_content_url, |
397 const std::string& resource_id, | 386 const std::string& resource_id, |
398 const google_apis::EntryActionCallback& callback) { | 387 const EntryActionCallback& callback) { |
399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
400 DCHECK(!callback.is_null()); | 389 DCHECK(!callback.is_null()); |
401 | 390 |
402 // TODO(kochi): Implement this. | 391 // TODO(kochi): Implement this. |
403 NOTREACHED(); | 392 NOTREACHED(); |
404 } | 393 } |
405 | 394 |
406 void DriveAPIService::InitiateUpload( | 395 void DriveAPIService::InitiateUpload( |
407 const google_apis::InitiateUploadParams& params, | 396 const InitiateUploadParams& params, |
408 const google_apis::InitiateUploadCallback& callback) { | 397 const InitiateUploadCallback& callback) { |
409 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
410 DCHECK(!callback.is_null()); | 399 DCHECK(!callback.is_null()); |
411 | 400 |
412 // TODO(kochi): Implement this. | 401 // TODO(kochi): Implement this. |
413 NOTREACHED(); | 402 NOTREACHED(); |
414 } | 403 } |
415 | 404 |
416 void DriveAPIService::ResumeUpload( | 405 void DriveAPIService::ResumeUpload( |
417 const google_apis::ResumeUploadParams& params, | 406 const ResumeUploadParams& params, |
418 const google_apis::ResumeUploadCallback& callback) { | 407 const ResumeUploadCallback& callback) { |
419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
420 DCHECK(!callback.is_null()); | 409 DCHECK(!callback.is_null()); |
421 | 410 |
422 // TODO(kochi): Implement this. | 411 // TODO(kochi): Implement this. |
423 NOTREACHED(); | 412 NOTREACHED(); |
424 } | 413 } |
425 | 414 |
426 void DriveAPIService::AuthorizeApp( | 415 void DriveAPIService::AuthorizeApp( |
427 const GURL& edit_url, | 416 const GURL& edit_url, |
428 const std::string& app_ids, | 417 const std::string& app_ids, |
429 const google_apis::AuthorizeAppCallback& callback) { | 418 const AuthorizeAppCallback& callback) { |
430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
431 DCHECK(!callback.is_null()); | 420 DCHECK(!callback.is_null()); |
432 | 421 |
433 // TODO(kochi): Implement this. | 422 // TODO(kochi): Implement this. |
434 NOTREACHED(); | 423 NOTREACHED(); |
435 } | 424 } |
436 | 425 |
437 bool DriveAPIService::HasAccessToken() const { | 426 bool DriveAPIService::HasAccessToken() const { |
438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
439 | 428 |
440 return runner_->auth_service()->HasAccessToken(); | 429 return runner_->auth_service()->HasAccessToken(); |
441 } | 430 } |
442 | 431 |
443 bool DriveAPIService::HasRefreshToken() const { | 432 bool DriveAPIService::HasRefreshToken() const { |
444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 433 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
445 | 434 |
446 return runner_->auth_service()->HasRefreshToken(); | 435 return runner_->auth_service()->HasRefreshToken(); |
447 } | 436 } |
448 | 437 |
449 google_apis::OperationRegistry* DriveAPIService::operation_registry() const { | 438 OperationRegistry* DriveAPIService::operation_registry() const { |
450 return runner_->operation_registry(); | 439 return runner_->operation_registry(); |
451 } | 440 } |
452 | 441 |
453 void DriveAPIService::OnOAuth2RefreshTokenChanged() { | 442 void DriveAPIService::OnOAuth2RefreshTokenChanged() { |
454 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 443 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
455 if (CanStartOperation()) { | 444 if (CanStartOperation()) { |
456 FOR_EACH_OBSERVER( | 445 FOR_EACH_OBSERVER( |
457 google_apis::DriveServiceObserver, observers_, | 446 DriveServiceObserver, observers_, |
458 OnReadyToPerformOperations()); | 447 OnReadyToPerformOperations()); |
459 } | 448 } |
460 } | 449 } |
461 | 450 |
462 void DriveAPIService::OnProgressUpdate( | 451 void DriveAPIService::OnProgressUpdate( |
463 const google_apis::OperationProgressStatusList& list) { | 452 const OperationProgressStatusList& list) { |
464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
465 FOR_EACH_OBSERVER( | 454 FOR_EACH_OBSERVER( |
466 google_apis::DriveServiceObserver, observers_, OnProgressUpdate(list)); | 455 DriveServiceObserver, observers_, OnProgressUpdate(list)); |
467 } | 456 } |
468 | 457 |
469 void DriveAPIService::OnAuthenticationFailed( | 458 void DriveAPIService::OnAuthenticationFailed(GDataErrorCode error) { |
470 google_apis::GDataErrorCode error) { | |
471 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
472 FOR_EACH_OBSERVER( | 460 FOR_EACH_OBSERVER( |
473 google_apis::DriveServiceObserver, observers_, | 461 DriveServiceObserver, observers_, |
474 OnAuthenticationFailed(error)); | 462 OnAuthenticationFailed(error)); |
475 } | 463 } |
476 | 464 |
477 } // namespace drive | 465 } // namespace google_apis |
OLD | NEW |