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

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

Issue 676873004: Intercept file Open/Close (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn Created 6 years, 1 month 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
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 7
8 #if defined(OS_POSIX)
9 #include "base/files/file_posix_hooks_internal.h"
10 #endif
11
8 namespace base { 12 namespace base {
9 13
10 File::Info::Info() 14 File::Info::Info()
11 : size(0), 15 : size(0),
12 is_directory(false), 16 is_directory(false),
13 is_symbolic_link(false) { 17 is_symbolic_link(false) {
14 } 18 }
15 19
16 File::Info::~Info() { 20 File::Info::~Info() {
17 } 21 }
(...skipping 13 matching lines...) Expand all
31 } 35 }
32 #endif 36 #endif
33 37
34 File::File(PlatformFile platform_file) 38 File::File(PlatformFile platform_file)
35 : file_(platform_file), 39 : file_(platform_file),
36 error_details_(FILE_OK), 40 error_details_(FILE_OK),
37 created_(false), 41 created_(false),
38 async_(false) { 42 async_(false) {
39 #if defined(OS_POSIX) 43 #if defined(OS_POSIX)
40 DCHECK_GE(platform_file, -1); 44 DCHECK_GE(platform_file, -1);
45 if (IsValid())
46 ProtectFileDescriptor(platform_file);
41 #endif 47 #endif
42 } 48 }
43 49
44 File::File(Error error_details) 50 File::File(Error error_details)
45 : error_details_(error_details), 51 : error_details_(error_details),
46 created_(false), 52 created_(false),
47 async_(false) { 53 async_(false) {
48 } 54 }
49 55
50 File::File(RValue other) 56 File::File(RValue other)
51 : file_(other.object->TakePlatformFile()), 57 : file_(other.object->TakePlatformFile()),
52 error_details_(other.object->error_details()), 58 error_details_(other.object->error_details()),
53 created_(other.object->created()), 59 created_(other.object->created()),
54 async_(other.object->async_) { 60 async_(other.object->async_) {
61 if (IsValid())
62 ProtectFileDescriptor(GetPlatformFile());
55 } 63 }
56 64
57 File::~File() { 65 File::~File() {
58 // Go through the AssertIOAllowed logic. 66 // Go through the AssertIOAllowed logic.
59 Close(); 67 Close();
60 } 68 }
61 69
62 File& File::operator=(RValue other) { 70 File& File::operator=(RValue other) {
63 if (this != other.object) { 71 if (this != other.object) {
64 Close(); 72 Close();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return "FILE_ERROR_IO"; 126 return "FILE_ERROR_IO";
119 case FILE_ERROR_MAX: 127 case FILE_ERROR_MAX:
120 break; 128 break;
121 } 129 }
122 130
123 NOTREACHED(); 131 NOTREACHED();
124 return ""; 132 return "";
125 } 133 }
126 134
127 } // namespace base 135 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698