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

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

Issue 172673002: Base: Don't check for thread restrictions when closing a file doesn't do IO. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « base/files/file.h ('k') | base/files/file_win.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 #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 <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return file_ >= 0; 210 return file_ >= 0;
211 } 211 }
212 212
213 PlatformFile File::TakePlatformFile() { 213 PlatformFile File::TakePlatformFile() {
214 PlatformFile file = file_; 214 PlatformFile file = file_;
215 file_ = kInvalidPlatformFileValue; 215 file_ = kInvalidPlatformFileValue;
216 return file; 216 return file;
217 } 217 }
218 218
219 void File::Close() { 219 void File::Close() {
220 base::ThreadRestrictions::AssertIOAllowed();
221 if (!IsValid()) 220 if (!IsValid())
222 return; 221 return;
223 222
223 base::ThreadRestrictions::AssertIOAllowed();
224 if (!IGNORE_EINTR(close(file_))) 224 if (!IGNORE_EINTR(close(file_)))
225 file_ = kInvalidPlatformFileValue; 225 file_ = kInvalidPlatformFileValue;
226 } 226 }
227 227
228 int64 File::Seek(Whence whence, int64 offset) { 228 int64 File::Seek(Whence whence, int64 offset) {
229 base::ThreadRestrictions::AssertIOAllowed(); 229 base::ThreadRestrictions::AssertIOAllowed();
230 DCHECK(IsValid()); 230 DCHECK(IsValid());
231 if (file_ < 0 || offset < 0) 231 if (file_ < 0 || offset < 0)
232 return -1; 232 return -1;
233 233
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 return FILE_ERROR_FAILED; 471 return FILE_ERROR_FAILED;
472 } 472 }
473 } 473 }
474 474
475 void File::SetPlatformFile(PlatformFile file) { 475 void File::SetPlatformFile(PlatformFile file) {
476 DCHECK_EQ(file_, kInvalidPlatformFileValue); 476 DCHECK_EQ(file_, kInvalidPlatformFileValue);
477 file_ = file; 477 file_ = file;
478 } 478 }
479 479
480 } // namespace base 480 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file.h ('k') | base/files/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698