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

Side by Side Diff: media/cast/logging/log_event_dispatcher.cc

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 "media/cast/logging/log_event_dispatcher.h" 5 #include "media/cast/logging/log_event_dispatcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
13 #include "media/cast/cast_environment.h" 14 #include "media/cast/cast_environment.h"
14 15
15 namespace media { 16 namespace media {
16 namespace cast { 17 namespace cast {
17 18
18 LogEventDispatcher::LogEventDispatcher(CastEnvironment* env) 19 LogEventDispatcher::LogEventDispatcher(CastEnvironment* env)
19 : env_(env), impl_(new Impl()) { 20 : env_(env), impl_(new Impl()) {
20 DCHECK(env_); 21 DCHECK(env_);
21 } 22 }
22 23
23 LogEventDispatcher::~LogEventDispatcher() {} 24 LogEventDispatcher::~LogEventDispatcher() {}
24 25
25 void LogEventDispatcher::DispatchFrameEvent( 26 void LogEventDispatcher::DispatchFrameEvent(
26 scoped_ptr<FrameEvent> event) const { 27 scoped_ptr<FrameEvent> event) const {
27 if (env_->CurrentlyOn(CastEnvironment::MAIN)) { 28 if (env_->CurrentlyOn(CastEnvironment::MAIN)) {
28 impl_->DispatchFrameEvent(event.Pass()); 29 impl_->DispatchFrameEvent(std::move(event));
29 } else { 30 } else {
30 env_->PostTask(CastEnvironment::MAIN, FROM_HERE, 31 env_->PostTask(CastEnvironment::MAIN, FROM_HERE,
31 base::Bind(&LogEventDispatcher::Impl::DispatchFrameEvent, 32 base::Bind(&LogEventDispatcher::Impl::DispatchFrameEvent,
32 impl_, base::Passed(&event))); 33 impl_, base::Passed(&event)));
33 } 34 }
34 } 35 }
35 36
36 void LogEventDispatcher::DispatchPacketEvent( 37 void LogEventDispatcher::DispatchPacketEvent(
37 scoped_ptr<PacketEvent> event) const { 38 scoped_ptr<PacketEvent> event) const {
38 if (env_->CurrentlyOn(CastEnvironment::MAIN)) { 39 if (env_->CurrentlyOn(CastEnvironment::MAIN)) {
39 impl_->DispatchPacketEvent(event.Pass()); 40 impl_->DispatchPacketEvent(std::move(event));
40 } else { 41 } else {
41 env_->PostTask(CastEnvironment::MAIN, FROM_HERE, 42 env_->PostTask(CastEnvironment::MAIN, FROM_HERE,
42 base::Bind(&LogEventDispatcher::Impl::DispatchPacketEvent, 43 base::Bind(&LogEventDispatcher::Impl::DispatchPacketEvent,
43 impl_, base::Passed(&event))); 44 impl_, base::Passed(&event)));
44 } 45 }
45 } 46 }
46 47
47 void LogEventDispatcher::DispatchBatchOfEvents( 48 void LogEventDispatcher::DispatchBatchOfEvents(
48 scoped_ptr<std::vector<FrameEvent>> frame_events, 49 scoped_ptr<std::vector<FrameEvent>> frame_events,
49 scoped_ptr<std::vector<PacketEvent>> packet_events) const { 50 scoped_ptr<std::vector<PacketEvent>> packet_events) const {
50 if (env_->CurrentlyOn(CastEnvironment::MAIN)) { 51 if (env_->CurrentlyOn(CastEnvironment::MAIN)) {
51 impl_->DispatchBatchOfEvents(frame_events.Pass(), packet_events.Pass()); 52 impl_->DispatchBatchOfEvents(std::move(frame_events),
53 std::move(packet_events));
52 } else { 54 } else {
53 env_->PostTask( 55 env_->PostTask(
54 CastEnvironment::MAIN, FROM_HERE, 56 CastEnvironment::MAIN, FROM_HERE,
55 base::Bind(&LogEventDispatcher::Impl::DispatchBatchOfEvents, impl_, 57 base::Bind(&LogEventDispatcher::Impl::DispatchBatchOfEvents, impl_,
56 base::Passed(&frame_events), base::Passed(&packet_events))); 58 base::Passed(&frame_events), base::Passed(&packet_events)));
57 } 59 }
58 } 60 }
59 61
60 void LogEventDispatcher::Subscribe(RawEventSubscriber* subscriber) { 62 void LogEventDispatcher::Subscribe(RawEventSubscriber* subscriber) {
61 if (env_->CurrentlyOn(CastEnvironment::MAIN)) { 63 if (env_->CurrentlyOn(CastEnvironment::MAIN)) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 130
129 void LogEventDispatcher::Impl::Unsubscribe(RawEventSubscriber* subscriber) { 131 void LogEventDispatcher::Impl::Unsubscribe(RawEventSubscriber* subscriber) {
130 const auto it = 132 const auto it =
131 std::find(subscribers_.begin(), subscribers_.end(), subscriber); 133 std::find(subscribers_.begin(), subscribers_.end(), subscriber);
132 DCHECK(it != subscribers_.end()); 134 DCHECK(it != subscribers_.end());
133 subscribers_.erase(it); 135 subscribers_.erase(it);
134 } 136 }
135 137
136 } // namespace cast 138 } // namespace cast
137 } // namespace media 139 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698