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

Side by Side Diff: base/files/file_posix.cc

Issue 2163063002: Make File::Duplicate() const (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert unneeded 'private:' label Created 4 years, 5 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
« no previous file with comments | « base/files/file.h ('k') | base/files/file_tracing.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 "base/files/file.h" 5 #include "base/files/file.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 File::Error File::Lock() { 363 File::Error File::Lock() {
364 SCOPED_FILE_TRACE("Lock"); 364 SCOPED_FILE_TRACE("Lock");
365 return CallFcntlFlock(file_.get(), true); 365 return CallFcntlFlock(file_.get(), true);
366 } 366 }
367 367
368 File::Error File::Unlock() { 368 File::Error File::Unlock() {
369 SCOPED_FILE_TRACE("Unlock"); 369 SCOPED_FILE_TRACE("Unlock");
370 return CallFcntlFlock(file_.get(), false); 370 return CallFcntlFlock(file_.get(), false);
371 } 371 }
372 372
373 File File::Duplicate() { 373 File File::Duplicate() const {
374 if (!IsValid()) 374 if (!IsValid())
375 return File(); 375 return File();
376 376
377 SCOPED_FILE_TRACE("Duplicate"); 377 SCOPED_FILE_TRACE("Duplicate");
378 378
379 PlatformFile other_fd = dup(GetPlatformFile()); 379 PlatformFile other_fd = dup(GetPlatformFile());
380 if (other_fd == -1) 380 if (other_fd == -1)
381 return File(OSErrorToFileError(errno)); 381 return File(OSErrorToFileError(errno));
382 382
383 File other(other_fd); 383 File other(other_fd);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 return !HANDLE_EINTR(fsync(file_.get())); 524 return !HANDLE_EINTR(fsync(file_.get()));
525 #endif 525 #endif
526 } 526 }
527 527
528 void File::SetPlatformFile(PlatformFile file) { 528 void File::SetPlatformFile(PlatformFile file) {
529 DCHECK(!file_.is_valid()); 529 DCHECK(!file_.is_valid());
530 file_.reset(file); 530 file_.reset(file);
531 } 531 }
532 532
533 } // namespace base 533 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file.h ('k') | base/files/file_tracing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698