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

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

Issue 14081010: Cleanup: Remove unnecessary ".get()" from scoped_ptrs<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some gtk issues Created 7 years, 8 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 "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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 Close(); 60 Close();
61 else 61 else
62 Cancel(); // Will delete the file. 62 Cancel(); // Will delete the file.
63 } 63 }
64 64
65 DownloadInterruptReason BaseFile::Initialize( 65 DownloadInterruptReason BaseFile::Initialize(
66 const base::FilePath& default_directory) { 66 const base::FilePath& default_directory) {
67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
68 DCHECK(!detached_); 68 DCHECK(!detached_);
69 69
70 if (file_stream_.get()) { 70 if (file_stream_) {
71 file_stream_->SetBoundNetLogSource(bound_net_log_); 71 file_stream_->SetBoundNetLogSource(bound_net_log_);
72 file_stream_->EnableErrorStatistics(); 72 file_stream_->EnableErrorStatistics();
73 } 73 }
74 74
75 if (full_path_.empty()) { 75 if (full_path_.empty()) {
76 base::FilePath initial_directory(default_directory); 76 base::FilePath initial_directory(default_directory);
77 base::FilePath temp_file; 77 base::FilePath temp_file;
78 if (initial_directory.empty()) { 78 if (initial_directory.empty()) {
79 initial_directory = 79 initial_directory =
80 GetContentClient()->browser()->GetDefaultDownloadDirectory(); 80 GetContentClient()->browser()->GetDefaultDownloadDirectory();
(...skipping 15 matching lines...) Expand all
96 DownloadInterruptReason BaseFile::AppendDataToFile(const char* data, 96 DownloadInterruptReason BaseFile::AppendDataToFile(const char* data,
97 size_t data_len) { 97 size_t data_len) {
98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
99 DCHECK(!detached_); 99 DCHECK(!detached_);
100 100
101 // NOTE(benwells): The above DCHECK won't be present in release builds, 101 // NOTE(benwells): The above DCHECK won't be present in release builds,
102 // so we log any occurences to see how common this error is in the wild. 102 // so we log any occurences to see how common this error is in the wild.
103 if (detached_) 103 if (detached_)
104 RecordDownloadCount(APPEND_TO_DETACHED_FILE_COUNT); 104 RecordDownloadCount(APPEND_TO_DETACHED_FILE_COUNT);
105 105
106 if (!file_stream_.get()) 106 if (!file_stream_)
107 return LogInterruptReason("No file stream on append", 0, 107 return LogInterruptReason("No file stream on append", 0,
108 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED); 108 DOWNLOAD_INTERRUPT_REASON_FILE_FAILED);
109 109
110 // TODO(phajdan.jr): get rid of this check. 110 // TODO(phajdan.jr): get rid of this check.
111 if (data_len == 0) 111 if (data_len == 0)
112 return DOWNLOAD_INTERRUPT_REASON_NONE; 112 return DOWNLOAD_INTERRUPT_REASON_NONE;
113 113
114 // The Write call below is not guaranteed to write all the data. 114 // The Write call below is not guaranteed to write all the data.
115 size_t write_count = 0; 115 size_t write_count = 0;
116 size_t len = data_len; 116 size_t len = data_len;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 DownloadInterruptReason BaseFile::Open() { 267 DownloadInterruptReason BaseFile::Open() {
268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
269 DCHECK(!detached_); 269 DCHECK(!detached_);
270 DCHECK(!full_path_.empty()); 270 DCHECK(!full_path_.empty());
271 271
272 bound_net_log_.BeginEvent( 272 bound_net_log_.BeginEvent(
273 net::NetLog::TYPE_DOWNLOAD_FILE_OPENED, 273 net::NetLog::TYPE_DOWNLOAD_FILE_OPENED,
274 base::Bind(&FileOpenedNetLogCallback, &full_path_, bytes_so_far_)); 274 base::Bind(&FileOpenedNetLogCallback, &full_path_, bytes_so_far_));
275 275
276 // Create a new file stream if it is not provided. 276 // Create a new file stream if it is not provided.
277 if (!file_stream_.get()) { 277 if (!file_stream_) {
278 CreateFileStream(); 278 CreateFileStream();
279 file_stream_->EnableErrorStatistics(); 279 file_stream_->EnableErrorStatistics();
280 int open_result = file_stream_->OpenSync( 280 int open_result = file_stream_->OpenSync(
281 full_path_, 281 full_path_,
282 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE); 282 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE);
283 if (open_result != net::OK) { 283 if (open_result != net::OK) {
284 ClearStream(); 284 ClearStream();
285 return LogNetError("Open", static_cast<net::Error>(open_result)); 285 return LogNetError("Open", static_cast<net::Error>(open_result));
286 } 286 }
287 287
(...skipping 27 matching lines...) Expand all
315 } 315 }
316 316
317 return DOWNLOAD_INTERRUPT_REASON_NONE; 317 return DOWNLOAD_INTERRUPT_REASON_NONE;
318 } 318 }
319 319
320 void BaseFile::Close() { 320 void BaseFile::Close() {
321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
322 322
323 bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_CLOSED); 323 bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_CLOSED);
324 324
325 if (file_stream_.get()) { 325 if (file_stream_) {
326 #if defined(OS_CHROMEOS) 326 #if defined(OS_CHROMEOS)
327 // Currently we don't really care about the return value, since if it fails 327 // Currently we don't really care about the return value, since if it fails
328 // theres not much we can do. But we might in the future. 328 // theres not much we can do. But we might in the future.
329 file_stream_->FlushSync(); 329 file_stream_->FlushSync();
330 #endif 330 #endif
331 ClearStream(); 331 ClearStream();
332 } 332 }
333 } 333 }
334 334
335 void BaseFile::ClearStream() { 335 void BaseFile::ClearStream() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 const char* operation, 369 const char* operation,
370 int os_error, 370 int os_error,
371 DownloadInterruptReason reason) { 371 DownloadInterruptReason reason) {
372 bound_net_log_.AddEvent( 372 bound_net_log_.AddEvent(
373 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, 373 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR,
374 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); 374 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason));
375 return reason; 375 return reason;
376 } 376 }
377 377
378 } // namespace content 378 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_protocol.cc ('k') | content/browser/download/download_item_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698