OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |