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

Side by Side Diff: content/browser/media/android/media_session.cc

Issue 1579613003: Add UMA to check whether requestAudioFocus() is successful. (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
« no previous file with comments | « no previous file | content/browser/media/android/media_session_uma_helper.h » ('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 "content/browser/media/android/media_session.h" 5 #include "content/browser/media/android/media_session.h"
6 6
7 #include "base/android/context_utils.h" 7 #include "base/android/context_utils.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "content/browser/media/android/media_session_observer.h" 9 #include "content/browser/media/android/media_session_observer.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 reinterpret_cast<intptr_t>(this))); 281 reinterpret_cast<intptr_t>(this)));
282 } 282 }
283 283
284 bool MediaSession::RequestSystemAudioFocus(Type type) { 284 bool MediaSession::RequestSystemAudioFocus(Type type) {
285 // During tests, j_media_session_ might be null. 285 // During tests, j_media_session_ might be null.
286 if (j_media_session_.is_null()) 286 if (j_media_session_.is_null())
287 return true; 287 return true;
288 288
289 JNIEnv* env = base::android::AttachCurrentThread(); 289 JNIEnv* env = base::android::AttachCurrentThread();
290 DCHECK(env); 290 DCHECK(env);
291 return Java_MediaSession_requestAudioFocus(env, j_media_session_.obj(), 291 bool result = Java_MediaSession_requestAudioFocus(env, j_media_session_.obj(),
292 type == Type::Transient); 292 type == Type::Transient);
293 uma_helper_.RecordRequestAudioFocusResult(result);
294 return result;
293 } 295 }
294 296
295 void MediaSession::AbandonSystemAudioFocusIfNeeded() { 297 void MediaSession::AbandonSystemAudioFocusIfNeeded() {
296 if (audio_focus_state_ == State::INACTIVE || !players_.empty()) 298 if (audio_focus_state_ == State::INACTIVE || !players_.empty())
297 return; 299 return;
298 300
299 // During tests, j_media_session_ might be null. 301 // During tests, j_media_session_ might be null.
300 if (!j_media_session_.is_null()) { 302 if (!j_media_session_.is_null()) {
301 JNIEnv* env = base::android::AttachCurrentThread(); 303 JNIEnv* env = base::android::AttachCurrentThread();
302 DCHECK(env); 304 DCHECK(env);
(...skipping 20 matching lines...) Expand all
323 case State::SUSPENDED: 325 case State::SUSPENDED:
324 uma_helper_.OnSessionSuspended(); 326 uma_helper_.OnSessionSuspended();
325 break; 327 break;
326 case State::INACTIVE: 328 case State::INACTIVE:
327 uma_helper_.OnSessionInactive(); 329 uma_helper_.OnSessionInactive();
328 break; 330 break;
329 } 331 }
330 } 332 }
331 333
332 } // namespace content 334 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/android/media_session_uma_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698