OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/utility/media_galleries/ipc_data_source.h" | 5 #include "chrome/utility/media_galleries/ipc_data_source.h" |
6 | 6 |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 8 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" |
9 #include "content/public/utility/utility_thread.h" | 9 #include "content/public/utility/utility_thread.h" |
10 | 10 |
11 namespace metadata { | 11 namespace metadata { |
12 | 12 |
13 IPCDataSource::IPCDataSource(int64_t total_size) | 13 IPCDataSource::IPCDataSource(int64_t total_size) |
14 : total_size_(total_size), | 14 : total_size_(total_size), |
15 utility_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 15 utility_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
16 next_request_id_(0) { | 16 next_request_id_(0) { |
17 data_source_thread_checker_.DetachFromThread(); | 17 data_source_thread_checker_.DetachFromThread(); |
18 } | 18 } |
19 | 19 |
20 IPCDataSource::~IPCDataSource() { | 20 IPCDataSource::~IPCDataSource() { |
21 DCHECK(utility_thread_checker_.CalledOnValidThread()); | 21 DCHECK(utility_thread_checker_.CalledOnValidThread()); |
22 } | 22 } |
23 | 23 |
24 void IPCDataSource::Stop() { | 24 void IPCDataSource::Stop() { |
25 DCHECK(data_source_thread_checker_.CalledOnValidThread()); | 25 DCHECK(data_source_thread_checker_.CalledOnValidThread()); |
26 } | 26 } |
27 | 27 |
| 28 void IPCDataSource::Abort() { |
| 29 DCHECK(data_source_thread_checker_.CalledOnValidThread()); |
| 30 } |
| 31 |
28 void IPCDataSource::Read(int64_t position, | 32 void IPCDataSource::Read(int64_t position, |
29 int size, | 33 int size, |
30 uint8_t* data, | 34 uint8_t* data, |
31 const DataSource::ReadCB& read_cb) { | 35 const DataSource::ReadCB& read_cb) { |
32 DCHECK(data_source_thread_checker_.CalledOnValidThread()); | 36 DCHECK(data_source_thread_checker_.CalledOnValidThread()); |
33 utility_task_runner_->PostTask( | 37 utility_task_runner_->PostTask( |
34 FROM_HERE, | 38 FROM_HERE, |
35 base::Bind(&IPCDataSource::ReadOnUtilityThread, base::Unretained(this), | 39 base::Bind(&IPCDataSource::ReadOnUtilityThread, base::Unretained(this), |
36 position, size, data, read_cb)); | 40 position, size, data, read_cb)); |
37 } | 41 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (it == pending_requests_.end()) | 108 if (it == pending_requests_.end()) |
105 return; | 109 return; |
106 | 110 |
107 std::copy(bytes.begin(), bytes.end(), it->second.destination); | 111 std::copy(bytes.begin(), bytes.end(), it->second.destination); |
108 it->second.callback.Run(bytes.size()); | 112 it->second.callback.Run(bytes.size()); |
109 | 113 |
110 pending_requests_.erase(it); | 114 pending_requests_.erase(it); |
111 } | 115 } |
112 | 116 |
113 } // namespace metadata | 117 } // namespace metadata |
OLD | NEW |