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

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

Issue 1101723004: Revert "Intercept base::File Open/Close" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « base/base.gyp ('k') | base/files/file_posix.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/timer/elapsed_timer.h" 8 #include "base/timer/elapsed_timer.h"
9 9
10 #if defined(OS_POSIX)
11 #include "base/files/file_posix_hooks_internal.h"
12 #endif
13
14 namespace base { 10 namespace base {
15 11
16 File::Info::Info() 12 File::Info::Info()
17 : size(0), 13 : size(0),
18 is_directory(false), 14 is_directory(false),
19 is_symbolic_link(false) { 15 is_symbolic_link(false) {
20 } 16 }
21 17
22 File::Info::~Info() { 18 File::Info::~Info() {
23 } 19 }
(...skipping 13 matching lines...) Expand all
37 } 33 }
38 #endif 34 #endif
39 35
40 File::File(PlatformFile platform_file) 36 File::File(PlatformFile platform_file)
41 : file_(platform_file), 37 : file_(platform_file),
42 error_details_(FILE_OK), 38 error_details_(FILE_OK),
43 created_(false), 39 created_(false),
44 async_(false) { 40 async_(false) {
45 #if defined(OS_POSIX) 41 #if defined(OS_POSIX)
46 DCHECK_GE(platform_file, -1); 42 DCHECK_GE(platform_file, -1);
47 if (IsValid())
48 ProtectFileDescriptor(platform_file);
49 #endif 43 #endif
50 } 44 }
51 45
52 File::File(Error error_details) 46 File::File(Error error_details)
53 : error_details_(error_details), 47 : error_details_(error_details),
54 created_(false), 48 created_(false),
55 async_(false) { 49 async_(false) {
56 } 50 }
57 51
58 File::File(RValue other) 52 File::File(RValue other)
59 : file_(other.object->TakePlatformFile()), 53 : file_(other.object->TakePlatformFile()),
60 error_details_(other.object->error_details()), 54 error_details_(other.object->error_details()),
61 created_(other.object->created()), 55 created_(other.object->created()),
62 async_(other.object->async_) { 56 async_(other.object->async_) {
63 #if defined(OS_POSIX)
64 if (IsValid())
65 ProtectFileDescriptor(GetPlatformFile());
66 #endif
67 } 57 }
68 58
69 File::~File() { 59 File::~File() {
70 // Go through the AssertIOAllowed logic. 60 // Go through the AssertIOAllowed logic.
71 Close(); 61 Close();
72 } 62 }
73 63
74 File& File::operator=(RValue other) { 64 File& File::operator=(RValue other) {
75 if (this != other.object) { 65 if (this != other.object) {
76 Close(); 66 Close();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 127 }
138 128
139 bool File::Flush() { 129 bool File::Flush() {
140 ElapsedTimer timer; 130 ElapsedTimer timer;
141 bool return_value = DoFlush(); 131 bool return_value = DoFlush();
142 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed()); 132 UMA_HISTOGRAM_TIMES("PlatformFile.FlushTime", timer.Elapsed());
143 return return_value; 133 return return_value;
144 } 134 }
145 135
146 } // namespace base 136 } // namespace base
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/files/file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698