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

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

Issue 1544293002: Convert Pass()→std::move() in //content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
15 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
16 #include "content/public/child/fixed_received_data.h" 17 #include "content/public/child/fixed_received_data.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 namespace { 21 namespace {
21 22
22 class DelegateThreadSafeReceivedData final 23 class DelegateThreadSafeReceivedData final
23 : public RequestPeer::ThreadSafeReceivedData { 24 : public RequestPeer::ThreadSafeReceivedData {
24 public: 25 public:
25 explicit DelegateThreadSafeReceivedData( 26 explicit DelegateThreadSafeReceivedData(
26 scoped_ptr<RequestPeer::ReceivedData> data) 27 scoped_ptr<RequestPeer::ReceivedData> data)
27 : data_(data.Pass()), task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 28 : data_(std::move(data)),
29 task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
28 ~DelegateThreadSafeReceivedData() override { 30 ~DelegateThreadSafeReceivedData() override {
29 if (!task_runner_->BelongsToCurrentThread()) { 31 if (!task_runner_->BelongsToCurrentThread()) {
30 // Delete the data on the original thread. 32 // Delete the data on the original thread.
31 task_runner_->DeleteSoon(FROM_HERE, data_.release()); 33 task_runner_->DeleteSoon(FROM_HERE, data_.release());
32 } 34 }
33 } 35 }
34 36
35 const char* payload() const override { return data_->payload(); } 37 const char* payload() const override { return data_->payload(); }
36 int length() const override { return data_->length(); } 38 int length() const override { return data_->length(); }
37 int encoded_length() const override { return data_->encoded_length(); } 39 int encoded_length() const override { return data_->encoded_length(); }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 base::AutoLock lock(context_->lock()); 298 base::AutoLock lock(context_->lock());
297 if (!context_->is_handle_active() && !context_->is_handle_locked()) { 299 if (!context_->is_handle_active() && !context_->is_handle_locked()) {
298 // No one is interested in the data. 300 // No one is interested in the data.
299 return; 301 return;
300 } 302 }
301 303
302 needs_notification = context_->IsEmpty(); 304 needs_notification = context_->IsEmpty();
303 scoped_ptr<RequestPeer::ThreadSafeReceivedData> data_to_pass; 305 scoped_ptr<RequestPeer::ThreadSafeReceivedData> data_to_pass;
304 if (mode_ == kApplyBackpressure) { 306 if (mode_ == kApplyBackpressure) {
305 data_to_pass = 307 data_to_pass =
306 make_scoped_ptr(new DelegateThreadSafeReceivedData(data.Pass())); 308 make_scoped_ptr(new DelegateThreadSafeReceivedData(std::move(data)));
307 } else { 309 } else {
308 data_to_pass = make_scoped_ptr(new FixedReceivedData(data.get())); 310 data_to_pass = make_scoped_ptr(new FixedReceivedData(data.get()));
309 } 311 }
310 context_->Push(data_to_pass.Pass()); 312 context_->Push(std::move(data_to_pass));
311 } 313 }
312 314
313 if (needs_notification) { 315 if (needs_notification) {
314 // We CAN issue the notification synchronously if the associated reader 316 // We CAN issue the notification synchronously if the associated reader
315 // lives in this thread, because this function cannot be called in the 317 // lives in this thread, because this function cannot be called in the
316 // client's callback. 318 // client's callback.
317 context_->Notify(); 319 context_->Notify();
318 } 320 }
319 } 321 }
320 322
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 SharedMemoryDataConsumerHandle::ReaderImpl* 475 SharedMemoryDataConsumerHandle::ReaderImpl*
474 SharedMemoryDataConsumerHandle::obtainReaderInternal(Client* client) { 476 SharedMemoryDataConsumerHandle::obtainReaderInternal(Client* client) {
475 return new ReaderImpl(context_, client); 477 return new ReaderImpl(context_, client);
476 } 478 }
477 479
478 const char* SharedMemoryDataConsumerHandle::debugName() const { 480 const char* SharedMemoryDataConsumerHandle::debugName() const {
479 return "SharedMemoryDataConsumerHandle"; 481 return "SharedMemoryDataConsumerHandle";
480 } 482 }
481 483
482 } // namespace content 484 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698