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

Side by Side Diff: net/base/file_stream_posix.cc

Issue 9349005: net: Rename FileStream::Open/Close with OpenSync/CloseSync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 10 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 | « net/base/file_stream.h ('k') | net/base/file_stream_unittest.cc » ('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 // For 64-bit file access (off_t = off64_t, lseek64, etc). 5 // For 64-bit file access (off_t = off64_t, lseek64, etc).
6 #define _FILE_OFFSET_BITS 64 6 #define _FILE_OFFSET_BITS 64
7 7
8 #include "net/base/file_stream.h" 8 #include "net/base/file_stream.h"
9 9
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 // If the file handle is opened with base::PLATFORM_FILE_ASYNC, we need to 335 // If the file handle is opened with base::PLATFORM_FILE_ASYNC, we need to
336 // make sure we will perform asynchronous File IO to it. 336 // make sure we will perform asynchronous File IO to it.
337 if (flags & base::PLATFORM_FILE_ASYNC) { 337 if (flags & base::PLATFORM_FILE_ASYNC) {
338 async_context_.reset(new AsyncContext()); 338 async_context_.reset(new AsyncContext());
339 } 339 }
340 } 340 }
341 341
342 FileStream::~FileStream() { 342 FileStream::~FileStream() {
343 if (auto_closed_) 343 if (auto_closed_)
344 Close(); 344 CloseSync();
345 345
346 bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_ALIVE, NULL); 346 bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_ALIVE, NULL);
347 } 347 }
348 348
349 void FileStream::Close() { 349 void FileStream::CloseSync() {
350 bound_net_log_.AddEvent(net::NetLog::TYPE_FILE_STREAM_CLOSE, NULL); 350 bound_net_log_.AddEvent(net::NetLog::TYPE_FILE_STREAM_CLOSE, NULL);
351 351
352 // Abort any existing asynchronous operations. 352 // Abort any existing asynchronous operations.
353 async_context_.reset(); 353 async_context_.reset();
354 354
355 if (file_ != base::kInvalidPlatformFileValue) { 355 if (file_ != base::kInvalidPlatformFileValue) {
356 if (!base::ClosePlatformFile(file_)) 356 if (!base::ClosePlatformFile(file_))
357 NOTREACHED(); 357 NOTREACHED();
358 file_ = base::kInvalidPlatformFileValue; 358 file_ = base::kInvalidPlatformFileValue;
359 359
360 bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_OPEN, NULL); 360 bound_net_log_.EndEvent(net::NetLog::TYPE_FILE_STREAM_OPEN, NULL);
361 } 361 }
362 } 362 }
363 363
364 int FileStream::Open(const FilePath& path, int open_flags) { 364 int FileStream::OpenSync(const FilePath& path, int open_flags) {
365 if (IsOpen()) { 365 if (IsOpen()) {
366 DLOG(FATAL) << "File is already open!"; 366 DLOG(FATAL) << "File is already open!";
367 return ERR_UNEXPECTED; 367 return ERR_UNEXPECTED;
368 } 368 }
369 369
370 bound_net_log_.BeginEvent( 370 bound_net_log_.BeginEvent(
371 net::NetLog::TYPE_FILE_STREAM_OPEN, 371 net::NetLog::TYPE_FILE_STREAM_OPEN,
372 make_scoped_refptr( 372 make_scoped_refptr(
373 new net::NetLogStringParameter("file_name", 373 new net::NetLogStringParameter("file_name",
374 path.AsUTF8Unsafe()))); 374 path.AsUTF8Unsafe())));
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 owner_bound_net_log.source()))); 559 owner_bound_net_log.source())));
560 560
561 owner_bound_net_log.AddEvent( 561 owner_bound_net_log.AddEvent(
562 net::NetLog::TYPE_FILE_STREAM_SOURCE, 562 net::NetLog::TYPE_FILE_STREAM_SOURCE,
563 make_scoped_refptr( 563 make_scoped_refptr(
564 new net::NetLogSourceParameter("source_dependency", 564 new net::NetLogSourceParameter("source_dependency",
565 bound_net_log_.source()))); 565 bound_net_log_.source())));
566 } 566 }
567 567
568 } // namespace net 568 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream.h ('k') | net/base/file_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698