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

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

Issue 1603013002: [chrome.displaySource] DisplaySourceConnectionDelegate::Connection interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from Antony 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 #ifndef EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_ 5 #ifndef EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_
6 #define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_ 6 #define EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "components/keyed_service/core/keyed_service.h" 9 #include "components/keyed_service/core/keyed_service.h"
10 #include "extensions/browser/api/display_source/display_source_connection_delega te.h" 10 #include "extensions/browser/api/display_source/display_source_connection_delega te.h"
11 #include "extensions/browser/event_router.h" 11 #include "extensions/browser/event_router.h"
12 12
13 namespace content { 13 namespace content {
14 class BrowserContext; 14 class BrowserContext;
15 } 15 }
16 16
17 namespace extensions { 17 namespace extensions {
18 18
19 // Observe listeners to 'onSinksUpdated' events. 19 // Observe listeners to 'onSinksUpdated' events.
20 // This class initiates/stops listening for the available sinks
21 // by the DisplaySourceConnectionDelegate, depending on whether
22 // there are existing listeners to 'onSinksUpdated' event.
20 class DisplaySourceEventRouter 23 class DisplaySourceEventRouter
21 : public KeyedService, 24 : public KeyedService,
22 public EventRouter::Observer, 25 public EventRouter::Observer,
23 public DisplaySourceConnectionDelegate::Observer { 26 public DisplaySourceConnectionDelegate::Observer {
24 public: 27 public:
25 static DisplaySourceEventRouter* Create( 28 static DisplaySourceEventRouter* Create(
26 content::BrowserContext* browser_context); 29 content::BrowserContext* browser_context);
27 30
28 ~DisplaySourceEventRouter() override; 31 ~DisplaySourceEventRouter() override;
29 32
30 private: 33 private:
31 explicit DisplaySourceEventRouter(content::BrowserContext* browser_context); 34 explicit DisplaySourceEventRouter(content::BrowserContext* browser_context);
32 35
33 // KeyedService overrides: 36 // KeyedService overrides:
34 void Shutdown() override; 37 void Shutdown() override;
35 38
36 // EventRouter::Observer overrides: 39 // EventRouter::Observer overrides:
37 void OnListenerAdded(const EventListenerInfo& details) override; 40 void OnListenerAdded(const EventListenerInfo& details) override;
38 void OnListenerRemoved(const EventListenerInfo& details) override; 41 void OnListenerRemoved(const EventListenerInfo& details) override;
39 42
40 // DisplaySourceConnectionDelegate::Observer overrides: 43 // DisplaySourceConnectionDelegate::Observer overrides:
41 void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) override; 44 void OnSinksUpdated(const DisplaySourceSinkInfoList& sinks) override;
45 void OnConnectionError(int sink_id,
46 DisplaySourceErrorType type,
47 const std::string& description) override {}
42 48
43 private: 49 private:
44 void StartOrStopListeningForSinksChanges(); 50 void StartOrStopListeningForSinksChanges();
45 51
46 content::BrowserContext* browser_context_; 52 content::BrowserContext* browser_context_;
47 bool listening_; 53 bool listening_;
48 54
49 DISALLOW_COPY_AND_ASSIGN(DisplaySourceEventRouter); 55 DISALLOW_COPY_AND_ASSIGN(DisplaySourceEventRouter);
50 }; 56 };
51 57
52 } // namespace extensions 58 } // namespace extensions
53 59
54 #endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_ 60 #endif // EXTENSIONS_BROWSER_API_DISPLAY_SOURCE_DISPLAY_SOURCE_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698