| OLD | NEW | 
|---|
| 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 "net/base/file_stream.h" | 5 #include "net/base/file_stream.h" | 
| 6 | 6 | 
| 7 #include "base/location.h" | 7 #include "base/location.h" | 
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" | 
| 9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" | 
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" | 
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 86   if (IsOpen()) { | 86   if (IsOpen()) { | 
| 87     DLOG(FATAL) << "File is already open!"; | 87     DLOG(FATAL) << "File is already open!"; | 
| 88     return ERR_UNEXPECTED; | 88     return ERR_UNEXPECTED; | 
| 89   } | 89   } | 
| 90 | 90 | 
| 91   open_flags_ = open_flags; | 91   open_flags_ = open_flags; | 
| 92   DCHECK(!is_async()); | 92   DCHECK(!is_async()); | 
| 93   return context_->OpenSync(path, open_flags_); | 93   return context_->OpenSync(path, open_flags_); | 
| 94 } | 94 } | 
| 95 | 95 | 
|  | 96 int FileStream::Close(const CompletionCallback& callback) { | 
|  | 97   DCHECK(is_async()); | 
|  | 98   context_->CloseAsync(callback); | 
|  | 99   return ERR_IO_PENDING; | 
|  | 100 } | 
|  | 101 | 
|  | 102 int FileStream::CloseSync() { | 
|  | 103   DCHECK(!is_async()); | 
|  | 104   base::ThreadRestrictions::AssertIOAllowed(); | 
|  | 105   context_->CloseSync(); | 
|  | 106   return OK; | 
|  | 107 } | 
|  | 108 | 
|  | 109 | 
| 96 bool FileStream::IsOpen() const { | 110 bool FileStream::IsOpen() const { | 
| 97   return context_->file() != base::kInvalidPlatformFileValue; | 111   return context_->file() != base::kInvalidPlatformFileValue; | 
| 98 } | 112 } | 
| 99 | 113 | 
| 100 int FileStream::Seek(Whence whence, | 114 int FileStream::Seek(Whence whence, | 
| 101                      int64 offset, | 115                      int64 offset, | 
| 102                      const Int64CompletionCallback& callback) { | 116                      const Int64CompletionCallback& callback) { | 
| 103   if (!IsOpen()) | 117   if (!IsOpen()) | 
| 104     return ERR_UNEXPECTED; | 118     return ERR_UNEXPECTED; | 
| 105 | 119 | 
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 276 | 290 | 
| 277   owner_bound_net_log.AddEvent(NetLog::TYPE_FILE_STREAM_SOURCE, | 291   owner_bound_net_log.AddEvent(NetLog::TYPE_FILE_STREAM_SOURCE, | 
| 278       bound_net_log_.source().ToEventParametersCallback()); | 292       bound_net_log_.source().ToEventParametersCallback()); | 
| 279 } | 293 } | 
| 280 | 294 | 
| 281 base::PlatformFile FileStream::GetPlatformFileForTesting() { | 295 base::PlatformFile FileStream::GetPlatformFileForTesting() { | 
| 282   return context_->file(); | 296   return context_->file(); | 
| 283 } | 297 } | 
| 284 | 298 | 
| 285 }  // namespace net | 299 }  // namespace net | 
| OLD | NEW | 
|---|