| 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 void OnReceivedData(int request_id, int data_offset, int data_length, | 41 // TODO(erikchen): This dummy variable is temporary and is only intended to be |
| 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, |
| 42 int encoded_data_length); | 47 int encoded_data_length); |
| 43 | 48 |
| 44 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 49 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 45 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 50 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 46 const scheduler::WebThreadImplForWorkerScheduler& background_thread_; | 51 const scheduler::WebThreadImplForWorkerScheduler& background_thread_; |
| 47 // This weakptr can only be dereferenced on the background thread. | 52 // This weakptr can only be dereferenced on the background thread. |
| 48 base::WeakPtr<ThreadedDataProvider> | 53 base::WeakPtr<ThreadedDataProvider> |
| 49 background_thread_resource_provider_; | 54 background_thread_resource_provider_; |
| 50 // This weakptr can only be dereferenced on the main thread. | 55 // This weakptr can only be dereferenced on the main thread. |
| 51 base::WeakPtr<ThreadedDataProvider> | 56 base::WeakPtr<ThreadedDataProvider> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 98 |
| 94 base::PickleIterator iter(message); | 99 base::PickleIterator iter(message); |
| 95 if (!iter.ReadInt(&request_id)) { | 100 if (!iter.ReadInt(&request_id)) { |
| 96 NOTREACHED() << "malformed resource message"; | 101 NOTREACHED() << "malformed resource message"; |
| 97 return true; | 102 return true; |
| 98 } | 103 } |
| 99 | 104 |
| 100 if (request_id == request_id_) { | 105 if (request_id == request_id_) { |
| 101 ResourceMsg_DataReceived::Schema::Param arg; | 106 ResourceMsg_DataReceived::Schema::Param arg; |
| 102 if (ResourceMsg_DataReceived::Read(&message, &arg)) { | 107 if (ResourceMsg_DataReceived::Read(&message, &arg)) { |
| 103 OnReceivedData(base::get<0>(arg), base::get<1>(arg), | 108 OnReceivedData(base::get<0>(arg), base::get<1>(arg), base::get<2>(arg), |
| 104 base::get<2>(arg), base::get<3>(arg)); | 109 base::get<3>(arg), base::get<4>(arg)); |
| 105 return true; | 110 return true; |
| 106 } | 111 } |
| 107 } | 112 } |
| 108 | 113 |
| 109 return false; | 114 return false; |
| 110 } | 115 } |
| 111 | 116 |
| 112 void DataProviderMessageFilter::OnReceivedData(int request_id, | 117 void DataProviderMessageFilter::OnReceivedData(int request_id, |
| 118 int /* dummy variable */, |
| 113 int data_offset, | 119 int data_offset, |
| 114 int data_length, | 120 int data_length, |
| 115 int encoded_data_length) { | 121 int encoded_data_length) { |
| 116 DCHECK(io_task_runner_->BelongsToCurrentThread()); | 122 DCHECK(io_task_runner_->BelongsToCurrentThread()); |
| 117 background_thread_.TaskRunner()->PostTask( | 123 background_thread_.TaskRunner()->PostTask( |
| 118 FROM_HERE, | 124 FROM_HERE, |
| 119 base::Bind(&ThreadedDataProvider::OnReceivedDataOnBackgroundThread, | 125 base::Bind(&ThreadedDataProvider::OnReceivedDataOnBackgroundThread, |
| 120 background_thread_resource_provider_, data_offset, data_length, | 126 background_thread_resource_provider_, data_offset, data_length, |
| 121 encoded_data_length)); | 127 encoded_data_length)); |
| 122 } | 128 } |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 DCHECK(threaded_data_receiver_->needsMainthreadDataCopy()); | 347 DCHECK(threaded_data_receiver_->needsMainthreadDataCopy()); |
| 342 DCHECK_EQ((size_t)data_length, data_copy->size()); | 348 DCHECK_EQ((size_t)data_length, data_copy->size()); |
| 343 } | 349 } |
| 344 | 350 |
| 345 threaded_data_receiver_->acceptMainthreadDataNotification( | 351 threaded_data_receiver_->acceptMainthreadDataNotification( |
| 346 (data_copy && !data_copy->empty()) ? &data_copy->front() : NULL, | 352 (data_copy && !data_copy->empty()) ? &data_copy->front() : NULL, |
| 347 data_length, encoded_data_length); | 353 data_length, encoded_data_length); |
| 348 } | 354 } |
| 349 | 355 |
| 350 } // namespace content | 356 } // namespace content |
| OLD | NEW |