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

Side by Side Diff: chrome/browser/chromeos/drive/drive_uploader.cc

Issue 11231068: drive: Fix a crash in gdata::DriveUploader::ResumeUpload() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/drive/drive_uploader.h" 5 #include "chrome/browser/chromeos/drive/drive_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"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 bytes_to_read)); 410 bytes_to_read));
411 } 411 }
412 412
413 void DriveUploader::ReadCompletionCallback( 413 void DriveUploader::ReadCompletionCallback(
414 int upload_id, 414 int upload_id,
415 int bytes_to_read, 415 int bytes_to_read,
416 int bytes_read) { 416 int bytes_read) {
417 // The Read is asynchronously executed on BrowserThread::UI, where 417 // The Read is asynchronously executed on BrowserThread::UI, where
418 // Read() was called. 418 // Read() was called.
419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
420 // Should be non-zero. FileStream::Read() returns 0 only at end-of-file,
421 // but we don't try to read from end-of-file.
422 DCHECK_NE(0, bytes_read);
420 DVLOG(1) << "ReadCompletionCallback bytes read=" << bytes_read; 423 DVLOG(1) << "ReadCompletionCallback bytes read=" << bytes_read;
421 424
422 UploadFileInfo* upload_file_info = GetUploadFileInfo(upload_id); 425 UploadFileInfo* upload_file_info = GetUploadFileInfo(upload_id);
423 if (!upload_file_info) 426 if (!upload_file_info)
424 return; 427 return;
425 428
426 // TODO(achuith): Handle this error. 429 if (bytes_read < 0) {
427 DCHECK_EQ(bytes_to_read, bytes_read); 430 LOG(ERROR) << "Error reading from file "
428 DCHECK_GT(bytes_read, 0) << "Error reading from file " 431 << upload_file_info->file_path.value();
429 << upload_file_info->file_path.value(); 432 UploadFailed(upload_file_info, google_apis::DRIVE_UPLOAD_ERROR_ABORT);
433 return;
434 }
430 435
431 upload_file_info->start_range = upload_file_info->end_range + 1; 436 upload_file_info->start_range = upload_file_info->end_range + 1;
432 upload_file_info->end_range = upload_file_info->start_range + 437 upload_file_info->end_range = upload_file_info->start_range +
433 bytes_read - 1; 438 bytes_read - 1;
434 439
435 ResumeUpload(upload_id); 440 ResumeUpload(upload_id);
436 } 441 }
437 442
438 void DriveUploader::ResumeUpload(int upload_id) { 443 void DriveUploader::ResumeUpload(int upload_id) {
439 UploadFileInfo* upload_file_info = GetUploadFileInfo(upload_id); 444 UploadFileInfo* upload_file_info = GetUploadFileInfo(upload_id);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 return "title=[" + title + 570 return "title=[" + title +
566 "], file_path=[" + file_path.AsUTF8Unsafe() + 571 "], file_path=[" + file_path.AsUTF8Unsafe() +
567 "], content_type=[" + content_type + 572 "], content_type=[" + content_type +
568 "], content_length=[" + base::UintToString(content_length) + 573 "], content_length=[" + base::UintToString(content_length) +
569 "], file_size=[" + base::UintToString(file_size) + 574 "], file_size=[" + base::UintToString(file_size) +
570 "], drive_path=[" + drive_path.AsUTF8Unsafe() + 575 "], drive_path=[" + drive_path.AsUTF8Unsafe() +
571 "]"; 576 "]";
572 } 577 }
573 578
574 } // namespace drive 579 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698