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 "content/child/threaded_data_provider.h" | 5 #include "content/child/threaded_data_provider.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" | 9 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" |
10 #include "content/child/child_process.h" | 10 #include "content/child/child_process.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 const base::WeakPtr<ThreadedDataProvider>& main_thread_resource_provider, | 31 const base::WeakPtr<ThreadedDataProvider>& main_thread_resource_provider, |
32 int request_id); | 32 int request_id); |
33 | 33 |
34 // IPC::ChannelProxy::MessageFilter | 34 // IPC::ChannelProxy::MessageFilter |
35 void OnFilterAdded(IPC::Sender* sender) final; | 35 void OnFilterAdded(IPC::Sender* sender) final; |
36 bool OnMessageReceived(const IPC::Message& message) final; | 36 bool OnMessageReceived(const IPC::Message& message) final; |
37 | 37 |
38 private: | 38 private: |
39 ~DataProviderMessageFilter() override {} | 39 ~DataProviderMessageFilter() override {} |
40 | 40 |
41 // TODO(erikchen): This dummy variable is temporary and is only intended to be | 41 void OnReceivedData(int request_id, int data_offset, int data_length, |
42 // present for one Canary release. http://crbug.com/527588. | |
43 void OnReceivedData(int request_id, | |
44 int /* dummy variable */, | |
45 int data_offset, | |
46 int data_length, | |
47 int encoded_data_length); | 42 int encoded_data_length); |
48 | 43 |
49 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 44 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
50 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 45 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
51 const scheduler::WebThreadImplForWorkerScheduler& background_thread_; | 46 const scheduler::WebThreadImplForWorkerScheduler& background_thread_; |
52 // This weakptr can only be dereferenced on the background thread. | 47 // This weakptr can only be dereferenced on the background thread. |
53 base::WeakPtr<ThreadedDataProvider> | 48 base::WeakPtr<ThreadedDataProvider> |
54 background_thread_resource_provider_; | 49 background_thread_resource_provider_; |
55 // This weakptr can only be dereferenced on the main thread. | 50 // This weakptr can only be dereferenced on the main thread. |
56 base::WeakPtr<ThreadedDataProvider> | 51 base::WeakPtr<ThreadedDataProvider> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 93 |
99 base::PickleIterator iter(message); | 94 base::PickleIterator iter(message); |
100 if (!iter.ReadInt(&request_id)) { | 95 if (!iter.ReadInt(&request_id)) { |
101 NOTREACHED() << "malformed resource message"; | 96 NOTREACHED() << "malformed resource message"; |
102 return true; | 97 return true; |
103 } | 98 } |
104 | 99 |
105 if (request_id == request_id_) { | 100 if (request_id == request_id_) { |
106 ResourceMsg_DataReceived::Schema::Param arg; | 101 ResourceMsg_DataReceived::Schema::Param arg; |
107 if (ResourceMsg_DataReceived::Read(&message, &arg)) { | 102 if (ResourceMsg_DataReceived::Read(&message, &arg)) { |
108 OnReceivedData(base::get<0>(arg), base::get<1>(arg), base::get<2>(arg), | 103 OnReceivedData(base::get<0>(arg), base::get<1>(arg), |
109 base::get<3>(arg), base::get<4>(arg)); | 104 base::get<2>(arg), base::get<3>(arg)); |
110 return true; | 105 return true; |
111 } | 106 } |
112 } | 107 } |
113 | 108 |
114 return false; | 109 return false; |
115 } | 110 } |
116 | 111 |
117 void DataProviderMessageFilter::OnReceivedData(int request_id, | 112 void DataProviderMessageFilter::OnReceivedData(int request_id, |
118 int /* dummy variable */, | |
119 int data_offset, | 113 int data_offset, |
120 int data_length, | 114 int data_length, |
121 int encoded_data_length) { | 115 int encoded_data_length) { |
122 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 116 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
123 background_thread_.TaskRunner()->PostTask( | 117 background_thread_.TaskRunner()->PostTask( |
124 FROM_HERE, | 118 FROM_HERE, |
125 base::Bind(&ThreadedDataProvider::OnReceivedDataOnBackgroundThread, | 119 base::Bind(&ThreadedDataProvider::OnReceivedDataOnBackgroundThread, |
126 background_thread_resource_provider_, data_offset, data_length, | 120 background_thread_resource_provider_, data_offset, data_length, |
127 encoded_data_length)); | 121 encoded_data_length)); |
128 } | 122 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 DCHECK(threaded_data_receiver_->needsMainthreadDataCopy()); | 341 DCHECK(threaded_data_receiver_->needsMainthreadDataCopy()); |
348 DCHECK_EQ((size_t)data_length, data_copy->size()); | 342 DCHECK_EQ((size_t)data_length, data_copy->size()); |
349 } | 343 } |
350 | 344 |
351 threaded_data_receiver_->acceptMainthreadDataNotification( | 345 threaded_data_receiver_->acceptMainthreadDataNotification( |
352 (data_copy && !data_copy->empty()) ? &data_copy->front() : NULL, | 346 (data_copy && !data_copy->empty()) ? &data_copy->front() : NULL, |
353 data_length, encoded_data_length); | 347 data_length, encoded_data_length); |
354 } | 348 } |
355 | 349 |
356 } // namespace content | 350 } // namespace content |
OLD | NEW |