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

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

Issue 98833003: drive: Fix DriveFileStreamReader to run cancel closure on the right thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_file_stream_reader.h" 5 #include "chrome/browser/chromeos/drive/drive_file_stream_reader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 353 }
354 DCHECK(entry); 354 DCHECK(entry);
355 355
356 net::HttpByteRange byte_range = in_byte_range; 356 net::HttpByteRange byte_range = in_byte_range;
357 if (!byte_range.ComputeBounds(entry->file_info().size())) { 357 if (!byte_range.ComputeBounds(entry->file_info().size())) {
358 // If |byte_range| is invalid (e.g. out of bounds), return with an error. 358 // If |byte_range| is invalid (e.g. out of bounds), return with an error.
359 // At the same time, we cancel the in-flight downloading operation if 359 // At the same time, we cancel the in-flight downloading operation if
360 // needed and and invalidate weak pointers so that we won't 360 // needed and and invalidate weak pointers so that we won't
361 // receive unwanted callbacks. 361 // receive unwanted callbacks.
362 if (!ui_cancel_download_closure.is_null()) 362 if (!ui_cancel_download_closure.is_null())
363 ui_cancel_download_closure.Run(); 363 RunTaskOnUIThread(ui_cancel_download_closure);
364 weak_ptr_factory_.InvalidateWeakPtrs(); 364 weak_ptr_factory_.InvalidateWeakPtrs();
365 callback.Run( 365 callback.Run(
366 net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, scoped_ptr<ResourceEntry>()); 366 net::ERR_REQUEST_RANGE_NOT_SATISFIABLE, scoped_ptr<ResourceEntry>());
367 return; 367 return;
368 } 368 }
369 369
370 // Note: both boundary of |byte_range| are inclusive. 370 // Note: both boundary of |byte_range| are inclusive.
371 int64 range_length = 371 int64 range_length =
372 byte_range.last_byte_position() - byte_range.first_byte_position() + 1; 372 byte_range.last_byte_position() - byte_range.first_byte_position() + 1;
373 DCHECK_GE(range_length, 0); 373 DCHECK_GE(range_length, 0);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // Note: due to the same reason, LocalReaderProxy::OnCompleted may 442 // Note: due to the same reason, LocalReaderProxy::OnCompleted may
443 // or may not be called. This is timing issue, and it is difficult to avoid 443 // or may not be called. This is timing issue, and it is difficult to avoid
444 // unfortunately. 444 // unfortunately.
445 if (error != FILE_ERROR_OK) { 445 if (error != FILE_ERROR_OK) {
446 callback.Run(FileErrorToNetError(error), scoped_ptr<ResourceEntry>()); 446 callback.Run(FileErrorToNetError(error), scoped_ptr<ResourceEntry>());
447 } 447 }
448 } 448 }
449 } 449 }
450 450
451 } // namespace drive 451 } // 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