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/google_apis/drive_api_operations.h" | 5 #include "chrome/browser/google_apis/drive_api_operations.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 callback.Run(response, file_resource.Pass()); | 71 callback.Run(response, file_resource.Pass()); |
72 } | 72 } |
73 | 73 |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 //============================== GetAboutOperation ============================= | 76 //============================== GetAboutOperation ============================= |
77 | 77 |
78 GetAboutOperation::GetAboutOperation( | 78 GetAboutOperation::GetAboutOperation( |
79 OperationRegistry* registry, | 79 OperationRunner* runner, |
80 net::URLRequestContextGetter* url_request_context_getter, | 80 net::URLRequestContextGetter* url_request_context_getter, |
81 const DriveApiUrlGenerator& url_generator, | 81 const DriveApiUrlGenerator& url_generator, |
82 const GetAboutResourceCallback& callback) | 82 const GetAboutResourceCallback& callback) |
83 : GetDataOperation(registry, url_request_context_getter, | 83 : GetDataOperation(runner, url_request_context_getter, |
84 base::Bind(&ParseJsonAndRun<AboutResource>, callback)), | 84 base::Bind(&ParseJsonAndRun<AboutResource>, callback)), |
85 url_generator_(url_generator) { | 85 url_generator_(url_generator) { |
86 DCHECK(!callback.is_null()); | 86 DCHECK(!callback.is_null()); |
87 } | 87 } |
88 | 88 |
89 GetAboutOperation::~GetAboutOperation() {} | 89 GetAboutOperation::~GetAboutOperation() {} |
90 | 90 |
91 GURL GetAboutOperation::GetURL() const { | 91 GURL GetAboutOperation::GetURL() const { |
92 return url_generator_.GetAboutUrl(); | 92 return url_generator_.GetAboutUrl(); |
93 } | 93 } |
94 | 94 |
95 //============================== GetApplistOperation =========================== | 95 //============================== GetApplistOperation =========================== |
96 | 96 |
97 GetApplistOperation::GetApplistOperation( | 97 GetApplistOperation::GetApplistOperation( |
98 OperationRegistry* registry, | 98 OperationRunner* runner, |
99 net::URLRequestContextGetter* url_request_context_getter, | 99 net::URLRequestContextGetter* url_request_context_getter, |
100 const DriveApiUrlGenerator& url_generator, | 100 const DriveApiUrlGenerator& url_generator, |
101 const GetDataCallback& callback) | 101 const GetDataCallback& callback) |
102 : GetDataOperation(registry, url_request_context_getter, callback), | 102 : GetDataOperation(runner, url_request_context_getter, callback), |
103 url_generator_(url_generator) { | 103 url_generator_(url_generator) { |
104 DCHECK(!callback.is_null()); | 104 DCHECK(!callback.is_null()); |
105 } | 105 } |
106 | 106 |
107 GetApplistOperation::~GetApplistOperation() {} | 107 GetApplistOperation::~GetApplistOperation() {} |
108 | 108 |
109 GURL GetApplistOperation::GetURL() const { | 109 GURL GetApplistOperation::GetURL() const { |
110 return url_generator_.GetApplistUrl(); | 110 return url_generator_.GetApplistUrl(); |
111 } | 111 } |
112 | 112 |
113 //============================ GetChangelistOperation ========================== | 113 //============================ GetChangelistOperation ========================== |
114 | 114 |
115 GetChangelistOperation::GetChangelistOperation( | 115 GetChangelistOperation::GetChangelistOperation( |
116 OperationRegistry* registry, | 116 OperationRunner* runner, |
117 net::URLRequestContextGetter* url_request_context_getter, | 117 net::URLRequestContextGetter* url_request_context_getter, |
118 const DriveApiUrlGenerator& url_generator, | 118 const DriveApiUrlGenerator& url_generator, |
119 bool include_deleted, | 119 bool include_deleted, |
120 int64 start_changestamp, | 120 int64 start_changestamp, |
121 int max_results, | 121 int max_results, |
122 const GetDataCallback& callback) | 122 const GetDataCallback& callback) |
123 : GetDataOperation(registry, url_request_context_getter, callback), | 123 : GetDataOperation(runner, url_request_context_getter, callback), |
124 url_generator_(url_generator), | 124 url_generator_(url_generator), |
125 include_deleted_(include_deleted), | 125 include_deleted_(include_deleted), |
126 start_changestamp_(start_changestamp), | 126 start_changestamp_(start_changestamp), |
127 max_results_(max_results) { | 127 max_results_(max_results) { |
128 DCHECK(!callback.is_null()); | 128 DCHECK(!callback.is_null()); |
129 } | 129 } |
130 | 130 |
131 GetChangelistOperation::~GetChangelistOperation() {} | 131 GetChangelistOperation::~GetChangelistOperation() {} |
132 | 132 |
133 GURL GetChangelistOperation::GetURL() const { | 133 GURL GetChangelistOperation::GetURL() const { |
134 return url_generator_.GetChangelistUrl( | 134 return url_generator_.GetChangelistUrl( |
135 include_deleted_, start_changestamp_, max_results_); | 135 include_deleted_, start_changestamp_, max_results_); |
136 } | 136 } |
137 | 137 |
138 //============================= GetFilelistOperation =========================== | 138 //============================= GetFilelistOperation =========================== |
139 | 139 |
140 GetFilelistOperation::GetFilelistOperation( | 140 GetFilelistOperation::GetFilelistOperation( |
141 OperationRegistry* registry, | 141 OperationRunner* runner, |
142 net::URLRequestContextGetter* url_request_context_getter, | 142 net::URLRequestContextGetter* url_request_context_getter, |
143 const DriveApiUrlGenerator& url_generator, | 143 const DriveApiUrlGenerator& url_generator, |
144 const std::string& search_string, | 144 const std::string& search_string, |
145 int max_results, | 145 int max_results, |
146 const GetDataCallback& callback) | 146 const GetDataCallback& callback) |
147 : GetDataOperation(registry, url_request_context_getter, callback), | 147 : GetDataOperation(runner, url_request_context_getter, callback), |
148 url_generator_(url_generator), | 148 url_generator_(url_generator), |
149 search_string_(search_string), | 149 search_string_(search_string), |
150 max_results_(max_results) { | 150 max_results_(max_results) { |
151 DCHECK(!callback.is_null()); | 151 DCHECK(!callback.is_null()); |
152 } | 152 } |
153 | 153 |
154 GetFilelistOperation::~GetFilelistOperation() {} | 154 GetFilelistOperation::~GetFilelistOperation() {} |
155 | 155 |
156 GURL GetFilelistOperation::GetURL() const { | 156 GURL GetFilelistOperation::GetURL() const { |
157 return url_generator_.GetFilelistUrl(search_string_, max_results_); | 157 return url_generator_.GetFilelistUrl(search_string_, max_results_); |
158 } | 158 } |
159 | 159 |
160 //=============================== GetFileOperation ============================= | 160 //=============================== GetFileOperation ============================= |
161 | 161 |
162 GetFileOperation::GetFileOperation( | 162 GetFileOperation::GetFileOperation( |
163 OperationRegistry* registry, | 163 OperationRunner* runner, |
164 net::URLRequestContextGetter* url_request_context_getter, | 164 net::URLRequestContextGetter* url_request_context_getter, |
165 const DriveApiUrlGenerator& url_generator, | 165 const DriveApiUrlGenerator& url_generator, |
166 const std::string& file_id, | 166 const std::string& file_id, |
167 const FileResourceCallback& callback) | 167 const FileResourceCallback& callback) |
168 : GetDataOperation(registry, url_request_context_getter, | 168 : GetDataOperation(runner, url_request_context_getter, |
169 base::Bind(&ParseJsonAndRun<FileResource>, callback)), | 169 base::Bind(&ParseJsonAndRun<FileResource>, callback)), |
170 url_generator_(url_generator), | 170 url_generator_(url_generator), |
171 file_id_(file_id) { | 171 file_id_(file_id) { |
172 DCHECK(!callback.is_null()); | 172 DCHECK(!callback.is_null()); |
173 } | 173 } |
174 | 174 |
175 GetFileOperation::~GetFileOperation() {} | 175 GetFileOperation::~GetFileOperation() {} |
176 | 176 |
177 GURL GetFileOperation::GetURL() const { | 177 GURL GetFileOperation::GetURL() const { |
178 return url_generator_.GetFileUrl(file_id_); | 178 return url_generator_.GetFileUrl(file_id_); |
179 } | 179 } |
180 | 180 |
181 namespace drive { | 181 namespace drive { |
182 | 182 |
183 //======================= ContinueGetFileListOperation ========================= | 183 //======================= ContinueGetFileListOperation ========================= |
184 | 184 |
185 ContinueGetFileListOperation::ContinueGetFileListOperation( | 185 ContinueGetFileListOperation::ContinueGetFileListOperation( |
186 OperationRegistry* registry, | 186 OperationRunner* runner, |
187 net::URLRequestContextGetter* url_request_context_getter, | 187 net::URLRequestContextGetter* url_request_context_getter, |
188 const GURL& url, | 188 const GURL& url, |
189 const GetDataCallback& callback) | 189 const GetDataCallback& callback) |
190 : GetDataOperation(registry, url_request_context_getter, callback), | 190 : GetDataOperation(runner, url_request_context_getter, callback), |
191 url_(url) { | 191 url_(url) { |
192 DCHECK(!callback.is_null()); | 192 DCHECK(!callback.is_null()); |
193 } | 193 } |
194 | 194 |
195 ContinueGetFileListOperation::~ContinueGetFileListOperation() {} | 195 ContinueGetFileListOperation::~ContinueGetFileListOperation() {} |
196 | 196 |
197 GURL ContinueGetFileListOperation::GetURL() const { | 197 GURL ContinueGetFileListOperation::GetURL() const { |
198 return url_; | 198 return url_; |
199 } | 199 } |
200 | 200 |
201 //========================== CreateDirectoryOperation ========================== | 201 //========================== CreateDirectoryOperation ========================== |
202 | 202 |
203 CreateDirectoryOperation::CreateDirectoryOperation( | 203 CreateDirectoryOperation::CreateDirectoryOperation( |
204 OperationRegistry* registry, | 204 OperationRunner* runner, |
205 net::URLRequestContextGetter* url_request_context_getter, | 205 net::URLRequestContextGetter* url_request_context_getter, |
206 const DriveApiUrlGenerator& url_generator, | 206 const DriveApiUrlGenerator& url_generator, |
207 const std::string& parent_resource_id, | 207 const std::string& parent_resource_id, |
208 const std::string& directory_name, | 208 const std::string& directory_name, |
209 const FileResourceCallback& callback) | 209 const FileResourceCallback& callback) |
210 : GetDataOperation(registry, url_request_context_getter, | 210 : GetDataOperation(runner, url_request_context_getter, |
211 base::Bind(&ParseJsonAndRun<FileResource>, callback)), | 211 base::Bind(&ParseJsonAndRun<FileResource>, callback)), |
212 url_generator_(url_generator), | 212 url_generator_(url_generator), |
213 parent_resource_id_(parent_resource_id), | 213 parent_resource_id_(parent_resource_id), |
214 directory_name_(directory_name) { | 214 directory_name_(directory_name) { |
215 DCHECK(!callback.is_null()); | 215 DCHECK(!callback.is_null()); |
216 DCHECK(!parent_resource_id_.empty()); | 216 DCHECK(!parent_resource_id_.empty()); |
217 DCHECK(!directory_name_.empty()); | 217 DCHECK(!directory_name_.empty()); |
218 } | 218 } |
219 | 219 |
220 CreateDirectoryOperation::~CreateDirectoryOperation() {} | 220 CreateDirectoryOperation::~CreateDirectoryOperation() {} |
(...skipping 24 matching lines...) Expand all Loading... |
245 base::JSONWriter::Write(&root, upload_content); | 245 base::JSONWriter::Write(&root, upload_content); |
246 | 246 |
247 DVLOG(1) << "CreateDirectory data: " << *upload_content_type << ", [" | 247 DVLOG(1) << "CreateDirectory data: " << *upload_content_type << ", [" |
248 << *upload_content << "]"; | 248 << *upload_content << "]"; |
249 return true; | 249 return true; |
250 } | 250 } |
251 | 251 |
252 //=========================== RenameResourceOperation ========================== | 252 //=========================== RenameResourceOperation ========================== |
253 | 253 |
254 RenameResourceOperation::RenameResourceOperation( | 254 RenameResourceOperation::RenameResourceOperation( |
255 OperationRegistry* registry, | 255 OperationRunner* runner, |
256 net::URLRequestContextGetter* url_request_context_getter, | 256 net::URLRequestContextGetter* url_request_context_getter, |
257 const DriveApiUrlGenerator& url_generator, | 257 const DriveApiUrlGenerator& url_generator, |
258 const std::string& resource_id, | 258 const std::string& resource_id, |
259 const std::string& new_name, | 259 const std::string& new_name, |
260 const EntryActionCallback& callback) | 260 const EntryActionCallback& callback) |
261 : EntryActionOperation(registry, url_request_context_getter, callback), | 261 : EntryActionOperation(runner, url_request_context_getter, callback), |
262 url_generator_(url_generator), | 262 url_generator_(url_generator), |
263 resource_id_(resource_id), | 263 resource_id_(resource_id), |
264 new_name_(new_name) { | 264 new_name_(new_name) { |
265 DCHECK(!callback.is_null()); | 265 DCHECK(!callback.is_null()); |
266 } | 266 } |
267 | 267 |
268 RenameResourceOperation::~RenameResourceOperation() {} | 268 RenameResourceOperation::~RenameResourceOperation() {} |
269 | 269 |
270 net::URLFetcher::RequestType RenameResourceOperation::GetRequestType() const { | 270 net::URLFetcher::RequestType RenameResourceOperation::GetRequestType() const { |
271 return net::URLFetcher::PATCH; | 271 return net::URLFetcher::PATCH; |
(...skipping 19 matching lines...) Expand all Loading... |
291 base::JSONWriter::Write(&root, upload_content); | 291 base::JSONWriter::Write(&root, upload_content); |
292 | 292 |
293 DVLOG(1) << "RenameResource data: " << *upload_content_type << ", [" | 293 DVLOG(1) << "RenameResource data: " << *upload_content_type << ", [" |
294 << *upload_content << "]"; | 294 << *upload_content << "]"; |
295 return true; | 295 return true; |
296 } | 296 } |
297 | 297 |
298 //=========================== CopyResourceOperation ============================ | 298 //=========================== CopyResourceOperation ============================ |
299 | 299 |
300 CopyResourceOperation::CopyResourceOperation( | 300 CopyResourceOperation::CopyResourceOperation( |
301 OperationRegistry* registry, | 301 OperationRunner* runner, |
302 net::URLRequestContextGetter* url_request_context_getter, | 302 net::URLRequestContextGetter* url_request_context_getter, |
303 const DriveApiUrlGenerator& url_generator, | 303 const DriveApiUrlGenerator& url_generator, |
304 const std::string& resource_id, | 304 const std::string& resource_id, |
305 const std::string& parent_resource_id, | 305 const std::string& parent_resource_id, |
306 const std::string& new_name, | 306 const std::string& new_name, |
307 const FileResourceCallback& callback) | 307 const FileResourceCallback& callback) |
308 : GetDataOperation(registry, url_request_context_getter, | 308 : GetDataOperation(runner, url_request_context_getter, |
309 base::Bind(&ParseJsonAndRun<FileResource>, callback)), | 309 base::Bind(&ParseJsonAndRun<FileResource>, callback)), |
310 url_generator_(url_generator), | 310 url_generator_(url_generator), |
311 resource_id_(resource_id), | 311 resource_id_(resource_id), |
312 parent_resource_id_(parent_resource_id), | 312 parent_resource_id_(parent_resource_id), |
313 new_name_(new_name) { | 313 new_name_(new_name) { |
314 DCHECK(!callback.is_null()); | 314 DCHECK(!callback.is_null()); |
315 } | 315 } |
316 | 316 |
317 CopyResourceOperation::~CopyResourceOperation() { | 317 CopyResourceOperation::~CopyResourceOperation() { |
318 } | 318 } |
(...skipping 25 matching lines...) Expand all Loading... |
344 base::JSONWriter::Write(&root, upload_content); | 344 base::JSONWriter::Write(&root, upload_content); |
345 | 345 |
346 DVLOG(1) << "CopyResource data: " << *upload_content_type << ", [" | 346 DVLOG(1) << "CopyResource data: " << *upload_content_type << ", [" |
347 << *upload_content << "]"; | 347 << *upload_content << "]"; |
348 return true; | 348 return true; |
349 } | 349 } |
350 | 350 |
351 //=========================== TrashResourceOperation =========================== | 351 //=========================== TrashResourceOperation =========================== |
352 | 352 |
353 TrashResourceOperation::TrashResourceOperation( | 353 TrashResourceOperation::TrashResourceOperation( |
354 OperationRegistry* registry, | 354 OperationRunner* runner, |
355 net::URLRequestContextGetter* url_request_context_getter, | 355 net::URLRequestContextGetter* url_request_context_getter, |
356 const DriveApiUrlGenerator& url_generator, | 356 const DriveApiUrlGenerator& url_generator, |
357 const std::string& resource_id, | 357 const std::string& resource_id, |
358 const EntryActionCallback& callback) | 358 const EntryActionCallback& callback) |
359 : EntryActionOperation(registry, url_request_context_getter, callback), | 359 : EntryActionOperation(runner, url_request_context_getter, callback), |
360 url_generator_(url_generator), | 360 url_generator_(url_generator), |
361 resource_id_(resource_id) { | 361 resource_id_(resource_id) { |
362 DCHECK(!callback.is_null()); | 362 DCHECK(!callback.is_null()); |
363 } | 363 } |
364 | 364 |
365 TrashResourceOperation::~TrashResourceOperation() {} | 365 TrashResourceOperation::~TrashResourceOperation() {} |
366 | 366 |
367 GURL TrashResourceOperation::GetURL() const { | 367 GURL TrashResourceOperation::GetURL() const { |
368 return url_generator_.GetFileTrashUrl(resource_id_); | 368 return url_generator_.GetFileTrashUrl(resource_id_); |
369 } | 369 } |
370 | 370 |
371 net::URLFetcher::RequestType TrashResourceOperation::GetRequestType() const { | 371 net::URLFetcher::RequestType TrashResourceOperation::GetRequestType() const { |
372 return net::URLFetcher::POST; | 372 return net::URLFetcher::POST; |
373 } | 373 } |
374 | 374 |
375 //========================== InsertResourceOperation =========================== | 375 //========================== InsertResourceOperation =========================== |
376 | 376 |
377 InsertResourceOperation::InsertResourceOperation( | 377 InsertResourceOperation::InsertResourceOperation( |
378 OperationRegistry* registry, | 378 OperationRunner* runner, |
379 net::URLRequestContextGetter* url_request_context_getter, | 379 net::URLRequestContextGetter* url_request_context_getter, |
380 const DriveApiUrlGenerator& url_generator, | 380 const DriveApiUrlGenerator& url_generator, |
381 const std::string& parent_resource_id, | 381 const std::string& parent_resource_id, |
382 const std::string& resource_id, | 382 const std::string& resource_id, |
383 const EntryActionCallback& callback) | 383 const EntryActionCallback& callback) |
384 : EntryActionOperation(registry, url_request_context_getter, callback), | 384 : EntryActionOperation(runner, url_request_context_getter, callback), |
385 url_generator_(url_generator), | 385 url_generator_(url_generator), |
386 parent_resource_id_(parent_resource_id), | 386 parent_resource_id_(parent_resource_id), |
387 resource_id_(resource_id) { | 387 resource_id_(resource_id) { |
388 DCHECK(!callback.is_null()); | 388 DCHECK(!callback.is_null()); |
389 } | 389 } |
390 | 390 |
391 InsertResourceOperation::~InsertResourceOperation() {} | 391 InsertResourceOperation::~InsertResourceOperation() {} |
392 | 392 |
393 GURL InsertResourceOperation::GetURL() const { | 393 GURL InsertResourceOperation::GetURL() const { |
394 return url_generator_.GetChildrenUrl(parent_resource_id_); | 394 return url_generator_.GetChildrenUrl(parent_resource_id_); |
(...skipping 12 matching lines...) Expand all Loading... |
407 base::JSONWriter::Write(&root, upload_content); | 407 base::JSONWriter::Write(&root, upload_content); |
408 | 408 |
409 DVLOG(1) << "InsertResource data: " << *upload_content_type << ", [" | 409 DVLOG(1) << "InsertResource data: " << *upload_content_type << ", [" |
410 << *upload_content << "]"; | 410 << *upload_content << "]"; |
411 return true; | 411 return true; |
412 } | 412 } |
413 | 413 |
414 //========================== DeleteResourceOperation =========================== | 414 //========================== DeleteResourceOperation =========================== |
415 | 415 |
416 DeleteResourceOperation::DeleteResourceOperation( | 416 DeleteResourceOperation::DeleteResourceOperation( |
417 OperationRegistry* registry, | 417 OperationRunner* runner, |
418 net::URLRequestContextGetter* url_request_context_getter, | 418 net::URLRequestContextGetter* url_request_context_getter, |
419 const DriveApiUrlGenerator& url_generator, | 419 const DriveApiUrlGenerator& url_generator, |
420 const std::string& parent_resource_id, | 420 const std::string& parent_resource_id, |
421 const std::string& resource_id, | 421 const std::string& resource_id, |
422 const EntryActionCallback& callback) | 422 const EntryActionCallback& callback) |
423 : EntryActionOperation(registry, url_request_context_getter, callback), | 423 : EntryActionOperation(runner, url_request_context_getter, callback), |
424 url_generator_(url_generator), | 424 url_generator_(url_generator), |
425 parent_resource_id_(parent_resource_id), | 425 parent_resource_id_(parent_resource_id), |
426 resource_id_(resource_id) { | 426 resource_id_(resource_id) { |
427 DCHECK(!callback.is_null()); | 427 DCHECK(!callback.is_null()); |
428 } | 428 } |
429 | 429 |
430 DeleteResourceOperation::~DeleteResourceOperation() {} | 430 DeleteResourceOperation::~DeleteResourceOperation() {} |
431 | 431 |
432 GURL DeleteResourceOperation::GetURL() const { | 432 GURL DeleteResourceOperation::GetURL() const { |
433 return url_generator_.GetChildrenUrlForRemoval( | 433 return url_generator_.GetChildrenUrlForRemoval( |
434 parent_resource_id_, resource_id_); | 434 parent_resource_id_, resource_id_); |
435 } | 435 } |
436 | 436 |
437 net::URLFetcher::RequestType DeleteResourceOperation::GetRequestType() const { | 437 net::URLFetcher::RequestType DeleteResourceOperation::GetRequestType() const { |
438 return net::URLFetcher::DELETE_REQUEST; | 438 return net::URLFetcher::DELETE_REQUEST; |
439 } | 439 } |
440 | 440 |
441 //======================= InitiateUploadNewFileOperation ======================= | 441 //======================= InitiateUploadNewFileOperation ======================= |
442 | 442 |
443 InitiateUploadNewFileOperation::InitiateUploadNewFileOperation( | 443 InitiateUploadNewFileOperation::InitiateUploadNewFileOperation( |
444 OperationRegistry* registry, | 444 OperationRunner* runner, |
445 net::URLRequestContextGetter* url_request_context_getter, | 445 net::URLRequestContextGetter* url_request_context_getter, |
446 const DriveApiUrlGenerator& url_generator, | 446 const DriveApiUrlGenerator& url_generator, |
447 const base::FilePath& drive_file_path, | 447 const base::FilePath& drive_file_path, |
448 const std::string& content_type, | 448 const std::string& content_type, |
449 int64 content_length, | 449 int64 content_length, |
450 const std::string& parent_resource_id, | 450 const std::string& parent_resource_id, |
451 const std::string& title, | 451 const std::string& title, |
452 const InitiateUploadCallback& callback) | 452 const InitiateUploadCallback& callback) |
453 : InitiateUploadOperationBase(registry, | 453 : InitiateUploadOperationBase(runner, |
454 url_request_context_getter, | 454 url_request_context_getter, |
455 callback, | 455 callback, |
456 drive_file_path, | 456 drive_file_path, |
457 content_type, | 457 content_type, |
458 content_length), | 458 content_length), |
459 url_generator_(url_generator), | 459 url_generator_(url_generator), |
460 parent_resource_id_(parent_resource_id), | 460 parent_resource_id_(parent_resource_id), |
461 title_(title) { | 461 title_(title) { |
462 } | 462 } |
463 | 463 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 base::JSONWriter::Write(&root, upload_content); | 495 base::JSONWriter::Write(&root, upload_content); |
496 | 496 |
497 DVLOG(1) << "InitiateUploadNewFile data: " << *upload_content_type << ", [" | 497 DVLOG(1) << "InitiateUploadNewFile data: " << *upload_content_type << ", [" |
498 << *upload_content << "]"; | 498 << *upload_content << "]"; |
499 return true; | 499 return true; |
500 } | 500 } |
501 | 501 |
502 //===================== InitiateUploadExistingFileOperation ==================== | 502 //===================== InitiateUploadExistingFileOperation ==================== |
503 | 503 |
504 InitiateUploadExistingFileOperation::InitiateUploadExistingFileOperation( | 504 InitiateUploadExistingFileOperation::InitiateUploadExistingFileOperation( |
505 OperationRegistry* registry, | 505 OperationRunner* runner, |
506 net::URLRequestContextGetter* url_request_context_getter, | 506 net::URLRequestContextGetter* url_request_context_getter, |
507 const DriveApiUrlGenerator& url_generator, | 507 const DriveApiUrlGenerator& url_generator, |
508 const base::FilePath& drive_file_path, | 508 const base::FilePath& drive_file_path, |
509 const std::string& content_type, | 509 const std::string& content_type, |
510 int64 content_length, | 510 int64 content_length, |
511 const std::string& resource_id, | 511 const std::string& resource_id, |
512 const std::string& etag, | 512 const std::string& etag, |
513 const InitiateUploadCallback& callback) | 513 const InitiateUploadCallback& callback) |
514 : InitiateUploadOperationBase(registry, | 514 : InitiateUploadOperationBase(runner, |
515 url_request_context_getter, | 515 url_request_context_getter, |
516 callback, | 516 callback, |
517 drive_file_path, | 517 drive_file_path, |
518 content_type, | 518 content_type, |
519 content_length), | 519 content_length), |
520 url_generator_(url_generator), | 520 url_generator_(url_generator), |
521 resource_id_(resource_id), | 521 resource_id_(resource_id), |
522 etag_(etag) { | 522 etag_(etag) { |
523 } | 523 } |
524 | 524 |
(...skipping 12 matching lines...) Expand all Loading... |
537 InitiateUploadExistingFileOperation::GetExtraRequestHeaders() const { | 537 InitiateUploadExistingFileOperation::GetExtraRequestHeaders() const { |
538 std::vector<std::string> headers( | 538 std::vector<std::string> headers( |
539 InitiateUploadOperationBase::GetExtraRequestHeaders()); | 539 InitiateUploadOperationBase::GetExtraRequestHeaders()); |
540 headers.push_back(util::GenerateIfMatchHeader(etag_)); | 540 headers.push_back(util::GenerateIfMatchHeader(etag_)); |
541 return headers; | 541 return headers; |
542 } | 542 } |
543 | 543 |
544 //============================ ResumeUploadOperation =========================== | 544 //============================ ResumeUploadOperation =========================== |
545 | 545 |
546 ResumeUploadOperation::ResumeUploadOperation( | 546 ResumeUploadOperation::ResumeUploadOperation( |
547 OperationRegistry* registry, | 547 OperationRunner* runner, |
548 net::URLRequestContextGetter* url_request_context_getter, | 548 net::URLRequestContextGetter* url_request_context_getter, |
549 const base::FilePath& drive_file_path, | 549 const base::FilePath& drive_file_path, |
550 const GURL& upload_location, | 550 const GURL& upload_location, |
551 int64 start_position, | 551 int64 start_position, |
552 int64 end_position, | 552 int64 end_position, |
553 int64 content_length, | 553 int64 content_length, |
554 const std::string& content_type, | 554 const std::string& content_type, |
555 const base::FilePath& local_file_path, | 555 const base::FilePath& local_file_path, |
556 const UploadRangeCallback& callback, | 556 const UploadRangeCallback& callback, |
557 const ProgressCallback& progress_callback) | 557 const ProgressCallback& progress_callback) |
558 : ResumeUploadOperationBase(registry, | 558 : ResumeUploadOperationBase(runner, |
559 url_request_context_getter, | 559 url_request_context_getter, |
560 drive_file_path, | 560 drive_file_path, |
561 upload_location, | 561 upload_location, |
562 start_position, | 562 start_position, |
563 end_position, | 563 end_position, |
564 content_length, | 564 content_length, |
565 content_type, | 565 content_type, |
566 local_file_path), | 566 local_file_path), |
567 callback_(callback), | 567 callback_(callback), |
568 progress_callback_(progress_callback) { | 568 progress_callback_(progress_callback) { |
569 DCHECK(!callback_.is_null()); | 569 DCHECK(!callback_.is_null()); |
570 } | 570 } |
571 | 571 |
572 ResumeUploadOperation::~ResumeUploadOperation() {} | 572 ResumeUploadOperation::~ResumeUploadOperation() {} |
573 | 573 |
574 void ResumeUploadOperation::OnRangeOperationComplete( | 574 void ResumeUploadOperation::OnRangeOperationComplete( |
575 const UploadRangeResponse& response, scoped_ptr<base::Value> value) { | 575 const UploadRangeResponse& response, scoped_ptr<base::Value> value) { |
576 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); | 576 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); |
577 } | 577 } |
578 | 578 |
579 void ResumeUploadOperation::OnURLFetchUploadProgress( | 579 void ResumeUploadOperation::OnURLFetchUploadProgress( |
580 const net::URLFetcher* source, int64 current, int64 total) { | 580 const net::URLFetcher* source, int64 current, int64 total) { |
581 if (!progress_callback_.is_null()) | 581 if (!progress_callback_.is_null()) |
582 progress_callback_.Run(current, total); | 582 progress_callback_.Run(current, total); |
583 } | 583 } |
584 | 584 |
585 //========================== GetUploadStatusOperation ========================== | 585 //========================== GetUploadStatusOperation ========================== |
586 | 586 |
587 GetUploadStatusOperation::GetUploadStatusOperation( | 587 GetUploadStatusOperation::GetUploadStatusOperation( |
588 OperationRegistry* registry, | 588 OperationRunner* runner, |
589 net::URLRequestContextGetter* url_request_context_getter, | 589 net::URLRequestContextGetter* url_request_context_getter, |
590 const base::FilePath& drive_file_path, | 590 const base::FilePath& drive_file_path, |
591 const GURL& upload_url, | 591 const GURL& upload_url, |
592 int64 content_length, | 592 int64 content_length, |
593 const UploadRangeCallback& callback) | 593 const UploadRangeCallback& callback) |
594 : GetUploadStatusOperationBase(registry, | 594 : GetUploadStatusOperationBase(runner, |
595 url_request_context_getter, | 595 url_request_context_getter, |
596 drive_file_path, | 596 drive_file_path, |
597 upload_url, | 597 upload_url, |
598 content_length), | 598 content_length), |
599 callback_(callback) { | 599 callback_(callback) { |
600 DCHECK(!callback.is_null()); | 600 DCHECK(!callback.is_null()); |
601 } | 601 } |
602 | 602 |
603 GetUploadStatusOperation::~GetUploadStatusOperation() {} | 603 GetUploadStatusOperation::~GetUploadStatusOperation() {} |
604 | 604 |
605 void GetUploadStatusOperation::OnRangeOperationComplete( | 605 void GetUploadStatusOperation::OnRangeOperationComplete( |
606 const UploadRangeResponse& response, scoped_ptr<base::Value> value) { | 606 const UploadRangeResponse& response, scoped_ptr<base::Value> value) { |
607 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); | 607 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); |
608 } | 608 } |
609 | 609 |
610 } // namespace drive | 610 } // namespace drive |
611 } // namespace google_apis | 611 } // namespace google_apis |
OLD | NEW |