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

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

Issue 11030044: Merge 159454 - Flush at the end of local file writing in FileWriter API. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: 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 | « chrome/browser/sessions/session_backend.cc ('k') | net/base/file_stream.h » ('j') | 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 "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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 520
521 void BaseFile::Close() { 521 void BaseFile::Close() {
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_->FlushSync();
531 #endif 531 #endif
532 file_stream_->CloseSync(); 532 file_stream_->CloseSync();
533 ClearStream(net::OK); 533 ClearStream(net::OK);
534 } 534 }
535 } 535 }
536 536
537 net::Error BaseFile::ClearStream(net::Error net_error) { 537 net::Error BaseFile::ClearStream(net::Error net_error) {
538 // This should only be called when we have a stream. 538 // This should only be called when we have a stream.
539 DCHECK(file_stream_.get() != NULL); 539 DCHECK(file_stream_.get() != NULL);
540 file_stream_.reset(); 540 file_stream_.reset();
(...skipping 15 matching lines...) Expand all
556 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const { 556 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const {
557 base::TimeDelta diff = current_time - start_tick_; 557 base::TimeDelta diff = current_time - start_tick_;
558 int64 diff_ms = diff.InMilliseconds(); 558 int64 diff_ms = diff.InMilliseconds();
559 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; 559 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms;
560 } 560 }
561 561
562 int64 BaseFile::CurrentSpeed() const { 562 int64 BaseFile::CurrentSpeed() const {
563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
564 return CurrentSpeedAtTime(base::TimeTicks::Now()); 564 return CurrentSpeedAtTime(base::TimeTicks::Now());
565 } 565 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_backend.cc ('k') | net/base/file_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698