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

Side by Side Diff: extensions/browser/api/display_source/display_source_event_router.cc

Issue 1540563002: [chrome.displaySource] Add WiFi Display session class skeleton and mojo service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments 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 "extensions/browser/api/display_source/display_source_event_router.h" 5 #include "extensions/browser/api/display_source/display_source_event_router.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
10 #include "extensions/browser/api/display_source/display_source_api.h" 10 #include "extensions/browser/api/display_source/display_source_api.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 return; 58 return;
59 59
60 bool should_listen = event_router->HasEventListener( 60 bool should_listen = event_router->HasEventListener(
61 api::display_source::OnSinksUpdated::kEventName); 61 api::display_source::OnSinksUpdated::kEventName);
62 if (should_listen && !listening_) { 62 if (should_listen && !listening_) {
63 DisplaySourceConnectionDelegate* delegate = 63 DisplaySourceConnectionDelegate* delegate =
64 DisplaySourceConnectionDelegateFactory::GetForBrowserContext( 64 DisplaySourceConnectionDelegateFactory::GetForBrowserContext(
65 browser_context_); 65 browser_context_);
66 if (delegate) { 66 if (delegate) {
67 delegate->AddObserver(this); 67 delegate->AddObserver(this);
68 delegate->StartWatchingSinks(); 68 delegate->StartWatchingAvailableSinks();
69 } 69 }
70 } 70 }
71 if (!should_listen && listening_) { 71 if (!should_listen && listening_) {
72 DisplaySourceConnectionDelegate* delegate = 72 DisplaySourceConnectionDelegate* delegate =
73 DisplaySourceConnectionDelegateFactory::GetForBrowserContext( 73 DisplaySourceConnectionDelegateFactory::GetForBrowserContext(
74 browser_context_); 74 browser_context_);
75 if (delegate) { 75 if (delegate) {
76 delegate->RemoveObserver(this); 76 delegate->RemoveObserver(this);
77 delegate->StopWatchingSinks(); 77 delegate->StopWatchingAvailableSinks();
78 } 78 }
79 } 79 }
80 80
81 listening_ = should_listen; 81 listening_ = should_listen;
82 } 82 }
83 83
84 void DisplaySourceEventRouter::OnSinksUpdated( 84 void DisplaySourceEventRouter::OnSinksUpdated(
85 const DisplaySourceSinkInfoList& sinks) { 85 const DisplaySourceSinkInfoList& sinks) {
86 EventRouter* event_router = EventRouter::Get(browser_context_); 86 EventRouter* event_router = EventRouter::Get(browser_context_);
87 if (!event_router) 87 if (!event_router)
88 return; 88 return;
89 scoped_ptr<base::ListValue> args( 89 scoped_ptr<base::ListValue> args(
90 api::display_source::OnSinksUpdated::Create(sinks)); 90 api::display_source::OnSinksUpdated::Create(sinks));
91 scoped_ptr<Event> sinks_updated_event(new Event( 91 scoped_ptr<Event> sinks_updated_event(new Event(
92 events::DISPLAY_SOURCE_ON_SINKS_UPDATED, 92 events::DISPLAY_SOURCE_ON_SINKS_UPDATED,
93 api::display_source::OnSinksUpdated::kEventName, std::move(args))); 93 api::display_source::OnSinksUpdated::kEventName, std::move(args)));
94 event_router->BroadcastEvent(std::move(sinks_updated_event)); 94 event_router->BroadcastEvent(std::move(sinks_updated_event));
95 } 95 }
96 96
97 DisplaySourceEventRouter* DisplaySourceEventRouter::Create( 97 DisplaySourceEventRouter* DisplaySourceEventRouter::Create(
98 content::BrowserContext* browser_context) { 98 content::BrowserContext* browser_context) {
99 return new DisplaySourceEventRouter(browser_context); 99 return new DisplaySourceEventRouter(browser_context);
100 } 100 }
101 101
102 } // namespace extensions 102 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698