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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_uploader.cc

Issue 10828385: Rename DocumentsServiceInterface to DriveServiceInterface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unnecessary includes. Created 8 years, 4 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 (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/gdata/gdata_uploader.h" 5 #include "chrome/browser/chromeos/gdata/gdata_uploader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "chrome/browser/chromeos/gdata/documents_service_interface.h" 11 #include "chrome/browser/chromeos/gdata/drive_service_interface.h"
12 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" 12 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h"
13 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h" 13 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h"
14 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" 14 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/download_item.h" 16 #include "content/public/browser/download_item.h"
17 #include "net/base/file_stream.h" 17 #include "net/base/file_stream.h"
18 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
19 19
20 using content::BrowserThread; 20 using content::BrowserThread;
21 21
22 namespace { 22 namespace {
23 23
24 // Google Documents List API requires uploading in chunks of 512kB. 24 // Google Documents List API requires uploading in chunks of 512kB.
25 const int64 kUploadChunkSize = 512 * 1024; 25 const int64 kUploadChunkSize = 512 * 1024;
26 26
27 // Maximum number of times we try to open a file before giving up. 27 // Maximum number of times we try to open a file before giving up.
28 const int kMaxFileOpenTries = 5; 28 const int kMaxFileOpenTries = 5;
29 29
30 } // namespace 30 } // namespace
31 31
32 namespace gdata { 32 namespace gdata {
33 33
34 GDataUploader::GDataUploader(DocumentsServiceInterface* documents_service) 34 GDataUploader::GDataUploader(DriveServiceInterface* drive_service)
35 : documents_service_(documents_service), 35 : drive_service_(drive_service),
36 next_upload_id_(0), 36 next_upload_id_(0),
37 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 37 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
38 } 38 }
39 39
40 GDataUploader::~GDataUploader() { 40 GDataUploader::~GDataUploader() {
41 } 41 }
42 42
43 int GDataUploader::UploadNewFile(scoped_ptr<UploadFileInfo> upload_file_info) { 43 int GDataUploader::UploadNewFile(scoped_ptr<UploadFileInfo> upload_file_info) {
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
45 DCHECK(upload_file_info.get()); 45 DCHECK(upload_file_info.get());
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 return; 233 return;
234 } 234 }
235 235
236 // Open succeeded, initiate the upload. 236 // Open succeeded, initiate the upload.
237 upload_file_info->should_retry_file_open = false; 237 upload_file_info->should_retry_file_open = false;
238 if (upload_file_info->initial_upload_location.is_empty()) { 238 if (upload_file_info->initial_upload_location.is_empty()) {
239 UploadFailed(scoped_ptr<UploadFileInfo>(upload_file_info), 239 UploadFailed(scoped_ptr<UploadFileInfo>(upload_file_info),
240 GDATA_FILE_ERROR_ABORT); 240 GDATA_FILE_ERROR_ABORT);
241 return; 241 return;
242 } 242 }
243 documents_service_->InitiateUpload( 243 drive_service_->InitiateUpload(
244 InitiateUploadParams(upload_file_info->upload_mode, 244 InitiateUploadParams(upload_file_info->upload_mode,
245 upload_file_info->title, 245 upload_file_info->title,
246 upload_file_info->content_type, 246 upload_file_info->content_type,
247 upload_file_info->content_length, 247 upload_file_info->content_length,
248 upload_file_info->initial_upload_location, 248 upload_file_info->initial_upload_location,
249 upload_file_info->gdata_path), 249 upload_file_info->gdata_path),
250 base::Bind(&GDataUploader::OnUploadLocationReceived, 250 base::Bind(&GDataUploader::OnUploadLocationReceived,
251 weak_ptr_factory_.GetWeakPtr(), 251 weak_ptr_factory_.GetWeakPtr(),
252 upload_file_info->upload_id)); 252 upload_file_info->upload_id));
253 } 253 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 bytes_read - 1; 359 bytes_read - 1;
360 360
361 ResumeUpload(upload_id); 361 ResumeUpload(upload_id);
362 } 362 }
363 363
364 void GDataUploader::ResumeUpload(int upload_id) { 364 void GDataUploader::ResumeUpload(int upload_id) {
365 UploadFileInfo* upload_file_info = GetUploadFileInfo(upload_id); 365 UploadFileInfo* upload_file_info = GetUploadFileInfo(upload_id);
366 if (!upload_file_info) 366 if (!upload_file_info)
367 return; 367 return;
368 368
369 documents_service_->ResumeUpload( 369 drive_service_->ResumeUpload(
370 ResumeUploadParams(upload_file_info->upload_mode, 370 ResumeUploadParams(upload_file_info->upload_mode,
371 upload_file_info->start_range, 371 upload_file_info->start_range,
372 upload_file_info->end_range, 372 upload_file_info->end_range,
373 upload_file_info->content_length, 373 upload_file_info->content_length,
374 upload_file_info->content_type, 374 upload_file_info->content_type,
375 upload_file_info->buf, 375 upload_file_info->buf,
376 upload_file_info->upload_location, 376 upload_file_info->upload_location,
377 upload_file_info->gdata_path), 377 upload_file_info->gdata_path),
378 base::Bind(&GDataUploader::OnResumeUploadResponseReceived, 378 base::Bind(&GDataUploader::OnResumeUploadResponseReceived,
379 weak_ptr_factory_.GetWeakPtr(), 379 weak_ptr_factory_.GetWeakPtr(),
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 if (!callback.is_null()) 453 if (!callback.is_null())
454 callback.Run(error, upload_file_info.Pass()); 454 callback.Run(error, upload_file_info.Pass());
455 } 455 }
456 456
457 void GDataUploader::RemoveUpload(int upload_id) { 457 void GDataUploader::RemoveUpload(int upload_id) {
458 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 458 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
459 pending_uploads_.erase(upload_id); 459 pending_uploads_.erase(upload_id);
460 } 460 }
461 461
462 } // namespace gdata 462 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_uploader.h ('k') | chrome/browser/chromeos/gdata/gdata_wapi_feed_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698