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

Side by Side Diff: chrome/browser/media/router/media_router_mojo_impl.h

Issue 1765143002: [Media Router] Add UMA histograms tracking component extension version/wakeups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move media_router_metrics_unittest to non_android Created 4 years, 9 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 CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/media/router/media_router_base.h" 27 #include "chrome/browser/media/router/media_router_base.h"
28 #include "chrome/browser/media/router/media_routes_observer.h" 28 #include "chrome/browser/media/router/media_routes_observer.h"
29 #include "mojo/public/cpp/bindings/binding.h" 29 #include "mojo/public/cpp/bindings/binding.h"
30 30
31 namespace content { 31 namespace content {
32 class BrowserContext; 32 class BrowserContext;
33 } 33 }
34 34
35 namespace extensions { 35 namespace extensions {
36 class EventPageTracker; 36 class EventPageTracker;
37 class Extension;
37 } 38 }
38 39
39 namespace media_router { 40 namespace media_router {
40 41
41 enum class MediaRouteProviderWakeReason; 42 enum class MediaRouteProviderWakeReason;
42 43
43 // MediaRouter implementation that delegates calls to the component extension. 44 // MediaRouter implementation that delegates calls to the component extension.
44 // Also handles the suspension and wakeup of the component extension. 45 // Also handles the suspension and wakeup of the component extension.
45 class MediaRouterMojoImpl : public MediaRouterBase, 46 class MediaRouterMojoImpl : public MediaRouterBase,
46 public interfaces::MediaRouter { 47 public interfaces::MediaRouter {
47 public: 48 public:
48 ~MediaRouterMojoImpl() override; 49 ~MediaRouterMojoImpl() override;
49 50
50 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle 51 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle
51 // MediaRouterObserver requests from the component extension given by 52 // MediaRouterObserver requests from the component extension given by
52 // |extension_id|. Creates the MediaRouterMojoImpl instance if it does not 53 // |extension|. Creates the MediaRouterMojoImpl instance if it does not
53 // exist. 54 // exist.
54 // Called by the Mojo module registry. 55 // Called by the Mojo module registry.
55 // |extension_id|: The ID of the component extension, used for querying 56 // |extension|: The component extension, used for querying
56 // suspension state. 57 // suspension state.
57 // |context|: The BrowserContext which owns the extension process. 58 // |context|: The BrowserContext which owns the extension process.
58 // |request|: The Mojo connection request used for binding. 59 // |request|: The Mojo connection request used for binding.
59 static void BindToRequest( 60 static void BindToRequest(
60 const std::string& extension_id, 61 const extensions::Extension* extension,
61 content::BrowserContext* context, 62 content::BrowserContext* context,
62 mojo::InterfaceRequest<interfaces::MediaRouter> request); 63 mojo::InterfaceRequest<interfaces::MediaRouter> request);
63 64
64 // MediaRouter implementation. 65 // MediaRouter implementation.
65 // Execution of the requests is delegated to the Do* methods, which can be 66 // Execution of the requests is delegated to the Do* methods, which can be
66 // enqueued for later use if the extension is temporarily suspended. 67 // enqueued for later use if the extension is temporarily suspended.
67 void CreateRoute(const MediaSource::Id& source_id, 68 void CreateRoute(const MediaSource::Id& source_id,
68 const MediaSink::Id& sink_id, 69 const MediaSink::Id& sink_id,
69 const GURL& origin, 70 const GURL& origin,
70 content::WebContents* web_contents, 71 content::WebContents* web_contents,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery); 176 DISALLOW_COPY_AND_ASSIGN(MediaRoutesQuery);
176 }; 177 };
177 178
178 // Standard constructor, used by 179 // Standard constructor, used by
179 // MediaRouterMojoImplFactory::GetApiForBrowserContext. 180 // MediaRouterMojoImplFactory::GetApiForBrowserContext.
180 explicit MediaRouterMojoImpl( 181 explicit MediaRouterMojoImpl(
181 extensions::EventPageTracker* event_page_tracker); 182 extensions::EventPageTracker* event_page_tracker);
182 183
183 // Binds |this| to a Mojo interface request, so that clients can acquire a 184 // Binds |this| to a Mojo interface request, so that clients can acquire a
184 // handle to a MediaRouterMojoImpl instance via the Mojo service connector. 185 // handle to a MediaRouterMojoImpl instance via the Mojo service connector.
185 // Stores the |extension_id| of the component extension. 186 // Stores the ID of |extension| in |media_route_provider_extension_id_|.
186 void BindToMojoRequest( 187 void BindToMojoRequest(
187 mojo::InterfaceRequest<interfaces::MediaRouter> request, 188 mojo::InterfaceRequest<interfaces::MediaRouter> request,
188 const std::string& extension_id); 189 const extensions::Extension& extension);
189 190
190 // Enqueues a closure for later execution by ExecutePendingRequests(). 191 // Enqueues a closure for later execution by ExecutePendingRequests().
191 void EnqueueTask(const base::Closure& closure); 192 void EnqueueTask(const base::Closure& closure);
192 193
193 // Runs a closure if the extension monitored by |extension_monitor_| is 194 // Runs a closure if the extension monitored by |extension_monitor_| is
194 // active, or defers it for later execution if the extension is suspended. 195 // active, or defers it for later execution if the extension is suspended.
195 void RunOrDefer(const base::Closure& request); 196 void RunOrDefer(const base::Closure& request);
196 197
197 // Dispatches the Mojo requests queued in |pending_requests_|. 198 // Dispatches the Mojo requests queued in |pending_requests_|.
198 void ExecutePendingRequests(); 199 void ExecutePendingRequests();
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 extensions::EventPageTracker* event_page_tracker_; 364 extensions::EventPageTracker* event_page_tracker_;
364 365
365 // GUID unique to each browser run. Component extension uses this to detect 366 // GUID unique to each browser run. Component extension uses this to detect
366 // when its persisted state was written by an older browser instance, and is 367 // when its persisted state was written by an older browser instance, and is
367 // therefore stale. 368 // therefore stale.
368 std::string instance_id_; 369 std::string instance_id_;
369 370
370 // The last reported sink availability from the media route provider manager. 371 // The last reported sink availability from the media route provider manager.
371 interfaces::MediaRouter::SinkAvailability availability_; 372 interfaces::MediaRouter::SinkAvailability availability_;
372 373
373 int wakeup_attempt_count_; 374 int wakeup_attempt_count_ = 0;
374 375
375 // Records the current reason the extension is being woken up. Is set to 376 // Records the current reason the extension is being woken up. Is set to
376 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. 377 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason.
377 MediaRouteProviderWakeReason current_wake_reason_; 378 MediaRouteProviderWakeReason current_wake_reason_;
378 379
380 // A flag to ensure that we record the provider version once, during the
381 // initial event page wakeup attempt.
382 bool provider_version_was_recorded_ = false;
383
379 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; 384 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_;
380 385
381 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); 386 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl);
382 }; 387 };
383 388
384 } // namespace media_router 389 } // namespace media_router
385 390
386 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ 391 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_router_metrics_unittest.cc ('k') | chrome/browser/media/router/media_router_mojo_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698