Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: content/child/threaded_data_provider.cc

Issue 1103813002: Make WebURLLoader capable of retaining received buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/scheduler/child/webthread_impl_for_worker_scheduler.h" 7 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h"
8 #include "content/child/child_process.h" 8 #include "content/child/child_process.h"
9 #include "content/child/child_thread_impl.h" 9 #include "content/child/child_thread_impl.h"
10 #include "content/child/ref_counted_shared_memory.h"
10 #include "content/child/resource_dispatcher.h" 11 #include "content/child/resource_dispatcher.h"
11 #include "content/child/thread_safe_sender.h" 12 #include "content/child/thread_safe_sender.h"
12 #include "content/common/resource_messages.h" 13 #include "content/common/resource_messages.h"
13 #include "ipc/ipc_sync_channel.h" 14 #include "ipc/ipc_sync_channel.h"
14 #include "third_party/WebKit/public/platform/WebThread.h" 15 #include "third_party/WebKit/public/platform/WebThread.h"
15 #include "third_party/WebKit/public/platform/WebThreadedDataReceiver.h" 16 #include "third_party/WebKit/public/platform/WebThreadedDataReceiver.h"
16 17
17 namespace content { 18 namespace content {
18 19
19 namespace { 20 namespace {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 base::Bind(&ThreadedDataProvider::OnReceivedDataOnBackgroundThread, 114 base::Bind(&ThreadedDataProvider::OnReceivedDataOnBackgroundThread,
114 background_thread_resource_provider_, data_offset, data_length, 115 background_thread_resource_provider_, data_offset, data_length,
115 encoded_data_length)); 116 encoded_data_length));
116 } 117 }
117 118
118 } // anonymous namespace 119 } // anonymous namespace
119 120
120 ThreadedDataProvider::ThreadedDataProvider( 121 ThreadedDataProvider::ThreadedDataProvider(
121 int request_id, 122 int request_id,
122 blink::WebThreadedDataReceiver* threaded_data_receiver, 123 blink::WebThreadedDataReceiver* threaded_data_receiver,
123 linked_ptr<base::SharedMemory> shm_buffer, 124 scoped_refptr<RefCountedSharedMemory> shm_buffer,
124 int shm_size, 125 int shm_size,
125 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) 126 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner)
126 : request_id_(request_id), 127 : request_id_(request_id),
127 shm_buffer_(shm_buffer), 128 shm_buffer_(shm_buffer),
128 shm_size_(shm_size), 129 shm_size_(shm_size),
129 background_thread_( 130 background_thread_(
130 static_cast<scheduler::WebThreadImplForWorkerScheduler&>( 131 static_cast<scheduler::WebThreadImplForWorkerScheduler&>(
131 *threaded_data_receiver->backgroundThread())), 132 *threaded_data_receiver->backgroundThread())),
132 ipc_channel_(ChildThreadImpl::current()->channel()), 133 ipc_channel_(ChildThreadImpl::current()->channel()),
133 threaded_data_receiver_(threaded_data_receiver), 134 threaded_data_receiver_(threaded_data_receiver),
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 queued_data_.clear(); 269 queued_data_.clear();
269 } 270 }
270 } 271 }
271 272
272 void ThreadedDataProvider::OnReceivedDataOnBackgroundThread( 273 void ThreadedDataProvider::OnReceivedDataOnBackgroundThread(
273 int data_offset, int data_length, int encoded_data_length) { 274 int data_offset, int data_length, int encoded_data_length) {
274 DCHECK(background_thread_.isCurrentThread()); 275 DCHECK(background_thread_.isCurrentThread());
275 DCHECK(shm_buffer_ != NULL); 276 DCHECK(shm_buffer_ != NULL);
276 277
277 CHECK_GE(shm_size_, data_offset + data_length); 278 CHECK_GE(shm_size_, data_offset + data_length);
278 const char* data_ptr = static_cast<char*>(shm_buffer_->memory()); 279 const char* data_ptr = static_cast<char*>(shm_buffer_->memory().memory());
279 CHECK(data_ptr); 280 CHECK(data_ptr);
280 CHECK(data_ptr + data_offset); 281 CHECK(data_ptr + data_offset);
281 282
282 if (resource_filter_active_) { 283 if (resource_filter_active_) {
283 ForwardAndACKData(data_ptr + data_offset, data_length, encoded_data_length); 284 ForwardAndACKData(data_ptr + data_offset, data_length, encoded_data_length);
284 } else { 285 } else {
285 // There's a brief interval between the point where we know the filter 286 // There's a brief interval between the point where we know the filter
286 // has been installed on the I/O thread, and when we know for sure there's 287 // has been installed on the I/O thread, and when we know for sure there's
287 // no more data coming in from the main thread (from before the filter 288 // no more data coming in from the main thread (from before the filter
288 // got added). If we get any data during that interval, we need to queue 289 // got added). If we get any data during that interval, we need to queue
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 DCHECK(threaded_data_receiver_->needsMainthreadDataCopy()); 341 DCHECK(threaded_data_receiver_->needsMainthreadDataCopy());
341 DCHECK_EQ((size_t)data_length, data_copy->size()); 342 DCHECK_EQ((size_t)data_length, data_copy->size());
342 } 343 }
343 344
344 threaded_data_receiver_->acceptMainthreadDataNotification( 345 threaded_data_receiver_->acceptMainthreadDataNotification(
345 (data_copy && !data_copy->empty()) ? &data_copy->front() : NULL, 346 (data_copy && !data_copy->empty()) ? &data_copy->front() : NULL,
346 data_length, encoded_data_length); 347 data_length, encoded_data_length);
347 } 348 }
348 349
349 } // namespace content 350 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698