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 "storage/browser/fileapi/local_file_stream_writer.h" | 5 #include "storage/browser/fileapi/local_file_stream_writer.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/profiler/scoped_profile.h" |
9 #include "net/base/file_stream.h" | 10 #include "net/base/file_stream.h" |
10 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 | 13 |
13 namespace storage { | 14 namespace storage { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 const int kOpenFlagsForWrite = base::File::FLAG_OPEN | | 18 const int kOpenFlagsForWrite = base::File::FLAG_OPEN | |
18 base::File::FLAG_WRITE | | 19 base::File::FLAG_WRITE | |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 base::Bind(&LocalFileStreamWriter::DidOpen, | 119 base::Bind(&LocalFileStreamWriter::DidOpen, |
119 weak_factory_.GetWeakPtr(), | 120 weak_factory_.GetWeakPtr(), |
120 error_callback, | 121 error_callback, |
121 main_operation)); | 122 main_operation)); |
122 } | 123 } |
123 | 124 |
124 void LocalFileStreamWriter::DidOpen( | 125 void LocalFileStreamWriter::DidOpen( |
125 const net::CompletionCallback& error_callback, | 126 const net::CompletionCallback& error_callback, |
126 const base::Closure& main_operation, | 127 const base::Closure& main_operation, |
127 int result) { | 128 int result) { |
| 129 // TODO(vadimt): Remove ScopedProfile below once crbug.com/423948 is fixed. |
| 130 tracked_objects::ScopedProfile tracking_profile( |
| 131 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 132 "423948 LocalFileStreamWriter::DidOpen")); |
| 133 |
128 DCHECK(has_pending_operation_); | 134 DCHECK(has_pending_operation_); |
129 DCHECK(stream_impl_.get()); | 135 DCHECK(stream_impl_.get()); |
130 | 136 |
131 if (CancelIfRequested()) | 137 if (CancelIfRequested()) |
132 return; | 138 return; |
133 | 139 |
134 if (result != net::OK) { | 140 if (result != net::OK) { |
135 has_pending_operation_ = false; | 141 has_pending_operation_ = false; |
136 stream_impl_.reset(NULL); | 142 stream_impl_.reset(NULL); |
137 error_callback.Run(result); | 143 error_callback.Run(result); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 return false; | 254 return false; |
249 | 255 |
250 net::CompletionCallback pending_cancel = cancel_callback_; | 256 net::CompletionCallback pending_cancel = cancel_callback_; |
251 has_pending_operation_ = false; | 257 has_pending_operation_ = false; |
252 cancel_callback_.Reset(); | 258 cancel_callback_.Reset(); |
253 pending_cancel.Run(net::OK); | 259 pending_cancel.Run(net::OK); |
254 return true; | 260 return true; |
255 } | 261 } |
256 | 262 |
257 } // namespace storage | 263 } // namespace storage |
OLD | NEW |