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

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 1568073002: Reduce string copies in GURL creation (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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/media/android/webmediaplayer_android.h" 5 #include "content/renderer/media/android/webmediaplayer_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
11 #include "base/android/build_info.h" 11 #include "base/android/build_info.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback_helpers.h" 13 #include "base/callback_helpers.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "cc/blink/web_layer_impl.h" 21 #include "cc/blink/web_layer_impl.h"
22 #include "cc/layers/video_layer.h" 22 #include "cc/layers/video_layer.h"
23 #include "content/public/child/url_conversion.h"
23 #include "content/public/common/content_client.h" 24 #include "content/public/common/content_client.h"
24 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
25 #include "content/public/common/renderer_preferences.h" 26 #include "content/public/common/renderer_preferences.h"
26 #include "content/public/renderer/render_frame.h" 27 #include "content/public/renderer/render_frame.h"
27 #include "content/renderer/media/android/renderer_demuxer_android.h" 28 #include "content/renderer/media/android/renderer_demuxer_android.h"
28 #include "content/renderer/media/android/renderer_media_player_manager.h" 29 #include "content/renderer/media/android/renderer_media_player_manager.h"
29 #include "content/renderer/media/cdm/render_cdm_factory.h" 30 #include "content/renderer/media/cdm/render_cdm_factory.h"
30 #include "content/renderer/media/cdm/renderer_cdm_manager.h" 31 #include "content/renderer/media/cdm/renderer_cdm_manager.h"
31 #include "content/renderer/render_frame_impl.h" 32 #include "content/renderer/render_frame_impl.h"
32 #include "content/renderer/render_thread_impl.h" 33 #include "content/renderer/render_thread_impl.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 return; 301 return;
301 } 302 }
302 DoLoad(load_type, url, cors_mode); 303 DoLoad(load_type, url, cors_mode);
303 } 304 }
304 305
305 void WebMediaPlayerAndroid::DoLoad(LoadType load_type, 306 void WebMediaPlayerAndroid::DoLoad(LoadType load_type,
306 const blink::WebURL& url, 307 const blink::WebURL& url,
307 CORSMode cors_mode) { 308 CORSMode cors_mode) {
308 DCHECK(main_thread_checker_.CalledOnValidThread()); 309 DCHECK(main_thread_checker_.CalledOnValidThread());
309 310
310 media::ReportMetrics(load_type, GURL(url), 311 media::ReportMetrics(
311 GURL(frame_->document().securityOrigin().toString())); 312 load_type, GURL(url),
313 WebStringToGURL(frame_->document().securityOrigin().toString()));
312 314
313 switch (load_type) { 315 switch (load_type) {
314 case LoadTypeURL: 316 case LoadTypeURL:
315 player_type_ = MEDIA_PLAYER_TYPE_URL; 317 player_type_ = MEDIA_PLAYER_TYPE_URL;
316 break; 318 break;
317 319
318 case LoadTypeMediaSource: 320 case LoadTypeMediaSource:
319 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE; 321 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE;
320 break; 322 break;
321 323
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 proxy_decryptor_.reset(new media::ProxyDecryptor( 1607 proxy_decryptor_.reset(new media::ProxyDecryptor(
1606 media_permission_, 1608 media_permission_,
1607 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo(), 1609 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo(),
1608 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, 1610 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded,
1609 weak_factory_.GetWeakPtr()), 1611 weak_factory_.GetWeakPtr()),
1610 base::Bind(&WebMediaPlayerAndroid::OnKeyError, 1612 base::Bind(&WebMediaPlayerAndroid::OnKeyError,
1611 weak_factory_.GetWeakPtr()), 1613 weak_factory_.GetWeakPtr()),
1612 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, 1614 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage,
1613 weak_factory_.GetWeakPtr()))); 1615 weak_factory_.GetWeakPtr())));
1614 1616
1615 GURL security_origin(frame_->document().securityOrigin().toString()); 1617 GURL security_origin(
1618 WebStringToGURL(frame_->document().securityOrigin().toString()));
1616 proxy_decryptor_->CreateCdm( 1619 proxy_decryptor_->CreateCdm(
1617 cdm_factory_, key_system, security_origin, 1620 cdm_factory_, key_system, security_origin,
1618 base::Bind(&WebMediaPlayerAndroid::OnCdmContextReady, 1621 base::Bind(&WebMediaPlayerAndroid::OnCdmContextReady,
1619 weak_factory_.GetWeakPtr())); 1622 weak_factory_.GetWeakPtr()));
1620 current_key_system_ = key_system; 1623 current_key_system_ = key_system;
1621 } 1624 }
1622 1625
1623 // We do not support run-time switching between key systems for now. 1626 // We do not support run-time switching between key systems for now.
1624 DCHECK(!current_key_system_.empty()); 1627 DCHECK(!current_key_system_.empty());
1625 if (key_system != current_key_system_) 1628 if (key_system != current_key_system_)
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 } 1936 }
1934 1937
1935 void WebMediaPlayerAndroid::ReportHLSMetrics() const { 1938 void WebMediaPlayerAndroid::ReportHLSMetrics() const {
1936 if (player_type_ != MEDIA_PLAYER_TYPE_URL) 1939 if (player_type_ != MEDIA_PLAYER_TYPE_URL)
1937 return; 1940 return;
1938 1941
1939 bool is_hls = IsHLSStream(); 1942 bool is_hls = IsHLSStream();
1940 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls); 1943 UMA_HISTOGRAM_BOOLEAN("Media.Android.IsHttpLiveStreamingMedia", is_hls);
1941 if (is_hls) { 1944 if (is_hls) {
1942 media::RecordOriginOfHLSPlayback( 1945 media::RecordOriginOfHLSPlayback(
1943 GURL(frame_->document().securityOrigin().toString())); 1946 WebStringToGURL(frame_->document().securityOrigin().toString()));
1944 } 1947 }
1945 1948
1946 // Assuming that |is_hls| is the ground truth, test predictions. 1949 // Assuming that |is_hls| is the ground truth, test predictions.
1947 bool is_hls_path = media::MediaCodecUtil::IsHLSPath(url_); 1950 bool is_hls_path = media::MediaCodecUtil::IsHLSPath(url_);
1948 bool is_hls_url = media::MediaCodecUtil::IsHLSURL(url_); 1951 bool is_hls_url = media::MediaCodecUtil::IsHLSURL(url_);
1949 MediaTypePredictionResult result = PREDICTION_RESULT_ALL_INCORRECT; 1952 MediaTypePredictionResult result = PREDICTION_RESULT_ALL_INCORRECT;
1950 if (is_hls_path == is_hls && is_hls_url == is_hls) { 1953 if (is_hls_path == is_hls && is_hls_url == is_hls) {
1951 result = PREDICTION_RESULT_ALL_CORRECT; 1954 result = PREDICTION_RESULT_ALL_CORRECT;
1952 } else if (is_hls_path == is_hls) { 1955 } else if (is_hls_path == is_hls) {
1953 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; 1956 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER;
1954 } else if (is_hls_url == is_hls) { 1957 } else if (is_hls_url == is_hls) {
1955 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; 1958 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER;
1956 } 1959 }
1957 UMA_HISTOGRAM_ENUMERATION( 1960 UMA_HISTOGRAM_ENUMERATION(
1958 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", 1961 "Media.Android.IsHttpLiveStreamingMediaPredictionResult",
1959 result, PREDICTION_RESULT_MAX); 1962 result, PREDICTION_RESULT_MAX);
1960 } 1963 }
1961 1964
1962 } // namespace content 1965 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698