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

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

Issue 2177243002: Use per-frame TaskRunner instead of thread's default in DataConsumerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_consumer_handle_unique_ptr
Patch Set: update Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/shared_memory_data_consumer_handle.h" 5 #include "content/child/shared_memory_data_consumer_handle.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "components/scheduler/child/web_task_runner_impl.h"
18 #include "content/public/child/fixed_received_data.h" 19 #include "content/public/child/fixed_received_data.h"
19 20
20 namespace content { 21 namespace content {
21 22
22 namespace { 23 namespace {
23 24
24 class DelegateThreadSafeReceivedData final 25 class DelegateThreadSafeReceivedData final
25 : public RequestPeer::ThreadSafeReceivedData { 26 : public RequestPeer::ThreadSafeReceivedData {
26 public: 27 public:
27 explicit DelegateThreadSafeReceivedData( 28 explicit DelegateThreadSafeReceivedData(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return result_; 113 return result_;
113 } 114 }
114 void set_result(Result r) { 115 void set_result(Result r) {
115 lock_.AssertAcquired(); 116 lock_.AssertAcquired();
116 result_ = r; 117 result_ = r;
117 } 118 }
118 void AcquireReaderLock(Client* client) { 119 void AcquireReaderLock(Client* client) {
119 lock_.AssertAcquired(); 120 lock_.AssertAcquired();
120 DCHECK(!notification_task_runner_); 121 DCHECK(!notification_task_runner_);
121 DCHECK(!client_); 122 DCHECK(!client_);
122 notification_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 123
124 blink::WebTaskRunner* task_runner =
125 client ? client->getTaskRunner() : nullptr;
126 if (task_runner) {
127 notification_task_runner_ =
128 scheduler::WebTaskRunnerImpl::GetBaseTaskRunner(*task_runner);
kinuko 2016/07/28 15:41:31 Per Sami's comment this would be a tentative solut
129 } else {
130 notification_task_runner_ = base::ThreadTaskRunnerHandle::Get();
131 }
123 client_ = client; 132 client_ = client;
124 if (client && !(IsEmpty() && result() == Ok)) { 133 if (client && !(IsEmpty() && result() == Ok)) {
125 // We cannot notify synchronously because the user doesn't have the reader 134 // We cannot notify synchronously because the user doesn't have the reader
126 // yet. 135 // yet.
127 notification_task_runner_->PostTask( 136 notification_task_runner_->PostTask(
128 FROM_HERE, base::Bind(&Context::NotifyInternal, this, false)); 137 FROM_HERE, base::Bind(&Context::NotifyInternal, this, false));
129 } 138 }
130 } 139 }
131 void ReleaseReaderLock() { 140 void ReleaseReaderLock() {
132 lock_.AssertAcquired(); 141 lock_.AssertAcquired();
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 std::unique_ptr<blink::WebDataConsumerHandle::Reader> 484 std::unique_ptr<blink::WebDataConsumerHandle::Reader>
476 SharedMemoryDataConsumerHandle::obtainReader(Client* client) { 485 SharedMemoryDataConsumerHandle::obtainReader(Client* client) {
477 return base::WrapUnique(new ReaderImpl(context_, client)); 486 return base::WrapUnique(new ReaderImpl(context_, client));
478 } 487 }
479 488
480 const char* SharedMemoryDataConsumerHandle::debugName() const { 489 const char* SharedMemoryDataConsumerHandle::debugName() const {
481 return "SharedMemoryDataConsumerHandle"; 490 return "SharedMemoryDataConsumerHandle";
482 } 491 }
483 492
484 } // namespace content 493 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698