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

Side by Side Diff: third_party/WebKit/Source/modules/mediasession/MediaSession.cpp

Issue 2665733003: Add rappor metrics to track Media Session API usage (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | tools/metrics/rappor/rappor.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "modules/mediasession/MediaSession.h" 5 #include "modules/mediasession/MediaSession.h"
6 6
7 #include "bindings/modules/v8/MediaSessionActionHandler.h" 7 #include "bindings/modules/v8/MediaSessionActionHandler.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/DocumentUserGestureToken.h" 9 #include "core/dom/DocumentUserGestureToken.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
11 #include "core/frame/LocalFrame.h" 11 #include "core/frame/LocalFrame.h"
12 #include "modules/mediasession/MediaMetadata.h" 12 #include "modules/mediasession/MediaMetadata.h"
13 #include "modules/mediasession/MediaMetadataSanitizer.h" 13 #include "modules/mediasession/MediaMetadataSanitizer.h"
14 #include "platform/UserGestureIndicator.h" 14 #include "platform/UserGestureIndicator.h"
15 #include "public/platform/InterfaceProvider.h" 15 #include "public/platform/InterfaceProvider.h"
16 #include "public/platform/Platform.h"
16 #include "wtf/Optional.h" 17 #include "wtf/Optional.h"
17 #include <memory> 18 #include <memory>
18 19
19 namespace blink { 20 namespace blink {
20 21
21 namespace { 22 namespace {
22 23
23 using ::blink::mojom::blink::MediaSessionAction; 24 using ::blink::mojom::blink::MediaSessionAction;
24 25
25 const AtomicString& mojomActionToActionName(MediaSessionAction action) { 26 const AtomicString& mojomActionToActionName(MediaSessionAction action) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 << "MediaSession::getService() is only available from a frame"; 199 << "MediaSession::getService() is only available from a frame";
199 Document* document = toDocument(getExecutionContext()); 200 Document* document = toDocument(getExecutionContext());
200 if (!document->frame()) 201 if (!document->frame())
201 return nullptr; 202 return nullptr;
202 203
203 InterfaceProvider* interfaceProvider = document->frame()->interfaceProvider(); 204 InterfaceProvider* interfaceProvider = document->frame()->interfaceProvider();
204 if (!interfaceProvider) 205 if (!interfaceProvider)
205 return nullptr; 206 return nullptr;
206 207
207 interfaceProvider->getInterface(mojo::MakeRequest(&m_service)); 208 interfaceProvider->getInterface(mojo::MakeRequest(&m_service));
208 if (m_service.get()) 209 if (m_service.get()) {
210 // Record the eTLD+1 of the frame using the API.
211 Platform::current()->recordRapporURL("Media.Session.APIUsage.Origin",
212 document->url());
209 m_service->SetClient(m_clientBinding.CreateInterfacePtrAndBind()); 213 m_service->SetClient(m_clientBinding.CreateInterfacePtrAndBind());
214 }
210 215
211 return m_service.get(); 216 return m_service.get();
212 } 217 }
213 218
214 void MediaSession::DidReceiveAction( 219 void MediaSession::DidReceiveAction(
215 blink::mojom::blink::MediaSessionAction action) { 220 blink::mojom::blink::MediaSessionAction action) {
216 DCHECK(getExecutionContext()->isDocument()); 221 DCHECK(getExecutionContext()->isDocument());
217 Document* document = toDocument(getExecutionContext()); 222 Document* document = toDocument(getExecutionContext());
218 UserGestureIndicator gestureIndicator( 223 UserGestureIndicator gestureIndicator(
219 DocumentUserGestureToken::create(document)); 224 DocumentUserGestureToken::create(document));
(...skipping 17 matching lines...) Expand all
237 visitor->trace(m_actionHandlers); 242 visitor->trace(m_actionHandlers);
238 ContextClient::trace(visitor); 243 ContextClient::trace(visitor);
239 } 244 }
240 245
241 DEFINE_TRACE_WRAPPERS(MediaSession) { 246 DEFINE_TRACE_WRAPPERS(MediaSession) {
242 for (auto handler : m_actionHandlers.values()) 247 for (auto handler : m_actionHandlers.values())
243 visitor->traceWrappers(handler); 248 visitor->traceWrappers(handler);
244 } 249 }
245 250
246 } // namespace blink 251 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/rappor/rappor.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698