| 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 #if defined(OS_ANDROID) |
| 97 int FileStream::OpenContentUrl(const GURL& content_url, int open_flags, |
| 98 const CompletionCallback& callback) { |
| 99 DCHECK(content_url.SchemeIsContent()); |
| 100 if (IsOpen()) { |
| 101 DLOG(FATAL) << "Content URL is already open!"; |
| 102 return ERR_UNEXPECTED; |
| 103 } |
| 104 |
| 105 open_flags_ = open_flags; |
| 106 DCHECK(is_async()); |
| 107 context_->OpenContentUrlAsync(content_url, open_flags, callback); |
| 108 return ERR_IO_PENDING; |
| 109 } |
| 110 |
| 111 int FileStream::OpenContentUrlSync(const GURL& content_url, int open_flags) { |
| 112 DCHECK(content_url.SchemeIsContent()); |
| 113 if (IsOpen()) { |
| 114 DLOG(FATAL) << "Content URL is already open!"; |
| 115 return ERR_UNEXPECTED; |
| 116 } |
| 117 |
| 118 open_flags_ = open_flags; |
| 119 DCHECK(!is_async()); |
| 120 return context_->OpenContentUrlSync(content_url, open_flags_); |
| 121 } |
| 122 #endif |
| 123 |
| 96 int FileStream::Close(const CompletionCallback& callback) { | 124 int FileStream::Close(const CompletionCallback& callback) { |
| 97 DCHECK(is_async()); | 125 DCHECK(is_async()); |
| 98 context_->CloseAsync(callback); | 126 context_->CloseAsync(callback); |
| 99 return ERR_IO_PENDING; | 127 return ERR_IO_PENDING; |
| 100 } | 128 } |
| 101 | 129 |
| 102 int FileStream::CloseSync() { | 130 int FileStream::CloseSync() { |
| 103 DCHECK(!is_async()); | 131 DCHECK(!is_async()); |
| 104 base::ThreadRestrictions::AssertIOAllowed(); | 132 base::ThreadRestrictions::AssertIOAllowed(); |
| 105 context_->CloseSync(); | 133 context_->CloseSync(); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 317 |
| 290 owner_bound_net_log.AddEvent(NetLog::TYPE_FILE_STREAM_SOURCE, | 318 owner_bound_net_log.AddEvent(NetLog::TYPE_FILE_STREAM_SOURCE, |
| 291 bound_net_log_.source().ToEventParametersCallback()); | 319 bound_net_log_.source().ToEventParametersCallback()); |
| 292 } | 320 } |
| 293 | 321 |
| 294 base::PlatformFile FileStream::GetPlatformFileForTesting() { | 322 base::PlatformFile FileStream::GetPlatformFileForTesting() { |
| 295 return context_->file(); | 323 return context_->file(); |
| 296 } | 324 } |
| 297 | 325 |
| 298 } // namespace net | 326 } // namespace net |
| OLD | NEW |