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

Side by Side Diff: content/browser/download/base_file.cc

Issue 10701050: net: Implement canceling of all async operations in FileStream. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Correct fix for UploadFileElementReader Created 8 years, 3 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
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 "content/browser/download/base_file.h" 5 #include "content/browser/download/base_file.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
523 523
524 bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_CLOSED); 524 bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_CLOSED);
525 525
526 if (file_stream_.get()) { 526 if (file_stream_.get()) {
527 #if defined(OS_CHROMEOS) 527 #if defined(OS_CHROMEOS)
528 // Currently we don't really care about the return value, since if it fails 528 // Currently we don't really care about the return value, since if it fails
529 // theres not much we can do. But we might in the future. 529 // theres not much we can do. But we might in the future.
530 file_stream_->Flush(); 530 file_stream_->Flush();
531 #endif 531 #endif
532 file_stream_->CloseSync();
533 ClearStream(net::OK); 532 ClearStream(net::OK);
534 } 533 }
535 } 534 }
536 535
537 net::Error BaseFile::ClearStream(net::Error net_error) { 536 net::Error BaseFile::ClearStream(net::Error net_error) {
538 // This should only be called when we have a stream. 537 // This should only be called when we have a stream.
539 DCHECK(file_stream_.get() != NULL); 538 DCHECK(file_stream_.get() != NULL);
540 file_stream_.reset(); 539 file_stream_.reset();
541 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_OPENED); 540 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_OPENED);
542 return net_error; 541 return net_error;
(...skipping 13 matching lines...) Expand all
556 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const { 555 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const {
557 base::TimeDelta diff = current_time - start_tick_; 556 base::TimeDelta diff = current_time - start_tick_;
558 int64 diff_ms = diff.InMilliseconds(); 557 int64 diff_ms = diff.InMilliseconds();
559 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; 558 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms;
560 } 559 }
561 560
562 int64 BaseFile::CurrentSpeed() const { 561 int64 BaseFile::CurrentSpeed() const {
563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 562 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
564 return CurrentSpeedAtTime(base::TimeTicks::Now()); 563 return CurrentSpeedAtTime(base::TimeTicks::Now());
565 } 564 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698