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 "content/child/fileapi/file_system_dispatcher.h" | 5 #include "content/child/fileapi/file_system_dispatcher.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 StatusCallback error_callback_; | 139 StatusCallback error_callback_; |
140 | 140 |
141 DISALLOW_COPY_AND_ASSIGN(CallbackDispatcher); | 141 DISALLOW_COPY_AND_ASSIGN(CallbackDispatcher); |
142 }; | 142 }; |
143 | 143 |
144 FileSystemDispatcher::FileSystemDispatcher() { | 144 FileSystemDispatcher::FileSystemDispatcher() { |
145 } | 145 } |
146 | 146 |
147 FileSystemDispatcher::~FileSystemDispatcher() { | 147 FileSystemDispatcher::~FileSystemDispatcher() { |
148 // Make sure we fire all the remaining callbacks. | 148 // Make sure we fire all the remaining callbacks. |
149 for (IDMap<CallbackDispatcher, IDMapOwnPointer>::iterator | 149 for (IDMap<std::unique_ptr<CallbackDispatcher>>::iterator iter(&dispatchers_); |
150 iter(&dispatchers_); !iter.IsAtEnd(); iter.Advance()) { | 150 !iter.IsAtEnd(); iter.Advance()) { |
151 int request_id = iter.GetCurrentKey(); | 151 int request_id = iter.GetCurrentKey(); |
152 CallbackDispatcher* dispatcher = iter.GetCurrentValue(); | 152 CallbackDispatcher* dispatcher = iter.GetCurrentValue(); |
153 DCHECK(dispatcher); | 153 DCHECK(dispatcher); |
154 dispatcher->DidFail(base::File::FILE_ERROR_ABORT); | 154 dispatcher->DidFail(base::File::FILE_ERROR_ABORT); |
155 dispatchers_.Remove(request_id); | 155 dispatchers_.Remove(request_id); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 bool FileSystemDispatcher::OnMessageReceived(const IPC::Message& msg) { | 159 bool FileSystemDispatcher::OnMessageReceived(const IPC::Message& msg) { |
160 bool handled = true; | 160 bool handled = true; |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 int64_t bytes, | 403 int64_t bytes, |
404 bool complete) { | 404 bool complete) { |
405 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); | 405 CallbackDispatcher* dispatcher = dispatchers_.Lookup(request_id); |
406 DCHECK(dispatcher); | 406 DCHECK(dispatcher); |
407 dispatcher->DidWrite(bytes, complete); | 407 dispatcher->DidWrite(bytes, complete); |
408 if (complete) | 408 if (complete) |
409 dispatchers_.Remove(request_id); | 409 dispatchers_.Remove(request_id); |
410 } | 410 } |
411 | 411 |
412 } // namespace content | 412 } // namespace content |
OLD | NEW |