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

Side by Side Diff: webkit/glue/webmediaplayer_impl.cc

Issue 8468011: Only report Media.AcceleratedCompositingActive for video-having playbacks and add Media.URLScheme. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: anonymous namespace Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/glue/webmediaplayer_impl.h" 5 #include "webkit/glue/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 message_loop_factory_(message_loop_factory), 113 message_loop_factory_(message_loop_factory),
114 paused_(true), 114 paused_(true),
115 seeking_(false), 115 seeking_(false),
116 playback_rate_(0.0f), 116 playback_rate_(0.0f),
117 pending_seek_(false), 117 pending_seek_(false),
118 client_(client), 118 client_(client),
119 proxy_(NULL), 119 proxy_(NULL),
120 delegate_(delegate), 120 delegate_(delegate),
121 media_stream_client_(media_stream_client), 121 media_stream_client_(media_stream_client),
122 media_log_(media_log), 122 media_log_(media_log),
123 is_accelerated_compositing_active_(false),
123 incremented_externally_allocated_memory_(false) { 124 incremented_externally_allocated_memory_(false) {
124 // Saves the current message loop. 125 // Saves the current message loop.
125 DCHECK(!main_loop_); 126 DCHECK(!main_loop_);
126 main_loop_ = MessageLoop::current(); 127 main_loop_ = MessageLoop::current();
127 media_log_->AddEvent( 128 media_log_->AddEvent(
128 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 129 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED));
129 } 130 }
130 131
131 bool WebMediaPlayerImpl::Initialize( 132 bool WebMediaPlayerImpl::Initialize(
132 WebKit::WebFrame* frame, 133 WebKit::WebFrame* frame,
(...skipping 12 matching lines...) Expand all
145 // Also, delaying GC until after player starts gets rid of starting lag -- 146 // Also, delaying GC until after player starts gets rid of starting lag --
146 // collection happens in parallel with playing. 147 // collection happens in parallel with playing.
147 // TODO(enal): remove when we get rid of per-audio-stream thread. 148 // TODO(enal): remove when we get rid of per-audio-stream thread.
148 if (!incremented_externally_allocated_memory_) { 149 if (!incremented_externally_allocated_memory_) {
149 MessageLoop::current()->PostTask( 150 MessageLoop::current()->PostTask(
150 FROM_HERE, 151 FROM_HERE,
151 base::Bind(&WebMediaPlayerImpl::IncrementExternallyAllocatedMemory, 152 base::Bind(&WebMediaPlayerImpl::IncrementExternallyAllocatedMemory,
152 AsWeakPtr())); 153 AsWeakPtr()));
153 } 154 }
154 155
155 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", 156 is_accelerated_compositing_active_ =
156 frame->view()->isAcceleratedCompositingActive()); 157 frame->view()->isAcceleratedCompositingActive();
157 158
158 pipeline_ = new media::PipelineImpl(pipeline_message_loop, media_log_); 159 pipeline_ = new media::PipelineImpl(pipeline_message_loop, media_log_);
159 160
160 // Also we want to be notified of |main_loop_| destruction. 161 // Also we want to be notified of |main_loop_| destruction.
161 main_loop_->AddDestructionObserver(this); 162 main_loop_->AddDestructionObserver(this);
162 163
163 // Creates the proxy. 164 // Creates the proxy.
164 proxy_ = new WebMediaPlayerProxy(main_loop_, this); 165 proxy_ = new WebMediaPlayerProxy(main_loop_, this);
165 web_video_renderer->SetWebMediaPlayerProxy(proxy_); 166 web_video_renderer->SetWebMediaPlayerProxy(proxy_);
166 proxy_->SetVideoRenderer(web_video_renderer); 167 proxy_->SetVideoRenderer(web_video_renderer);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (delegate_) 231 if (delegate_)
231 delegate_->PlayerGone(this); 232 delegate_->PlayerGone(this);
232 233
233 // Finally tell the |main_loop_| we don't want to be notified of destruction 234 // Finally tell the |main_loop_| we don't want to be notified of destruction
234 // event. 235 // event.
235 if (main_loop_) { 236 if (main_loop_) {
236 main_loop_->RemoveDestructionObserver(this); 237 main_loop_->RemoveDestructionObserver(this);
237 } 238 }
238 } 239 }
239 240
241 namespace {
242
243 // Helper enum for reporting scheme histograms.
244 enum URLSchemeForHistogram {
245 kUnknownURLScheme,
246 kMissingURLScheme,
247 kHttpURLScheme,
248 kHttpsURLScheme,
249 kFtpURLScheme,
250 kChromeExtensionURLScheme,
251 kJavascriptURLScheme,
252 kFileURLScheme,
253 kBlobURLScheme,
254 kDataURLScheme,
255 kMaxURLScheme = kDataURLScheme // Must be equal to highest enum value.
256 };
257
258 URLSchemeForHistogram URLScheme(const GURL& url) {
259 if (!url.has_scheme()) return kMissingURLScheme;
260 if (url.SchemeIs("http")) return kHttpURLScheme;
261 if (url.SchemeIs("https")) return kHttpsURLScheme;
262 if (url.SchemeIs("ftp")) return kFtpURLScheme;
263 if (url.SchemeIs("chrome-extension")) return kChromeExtensionURLScheme;
264 if (url.SchemeIs("javascript")) return kJavascriptURLScheme;
265 if (url.SchemeIs("file")) return kFileURLScheme;
266 if (url.SchemeIs("blob")) return kBlobURLScheme;
267 if (url.SchemeIs("data")) return kDataURLScheme;
268 return kUnknownURLScheme;
269 }
270
271 } // anonymous namespace
272
240 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { 273 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) {
241 DCHECK_EQ(main_loop_, MessageLoop::current()); 274 DCHECK_EQ(main_loop_, MessageLoop::current());
242 DCHECK(proxy_); 275 DCHECK(proxy_);
243 276
277 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(url), kMaxURLScheme);
278
244 if (media_stream_client_) { 279 if (media_stream_client_) {
245 bool has_video = false; 280 bool has_video = false;
246 bool has_audio = false; 281 bool has_audio = false;
247 scoped_refptr<media::VideoDecoder> new_decoder = 282 scoped_refptr<media::VideoDecoder> new_decoder =
248 media_stream_client_->GetVideoDecoder(url, message_loop_factory_.get()); 283 media_stream_client_->GetVideoDecoder(url, message_loop_factory_.get());
249 if (new_decoder.get()) { 284 if (new_decoder.get()) {
250 // Remove the default decoder. 285 // Remove the default decoder.
251 scoped_refptr<media::VideoDecoder> old_videodecoder; 286 scoped_refptr<media::VideoDecoder> old_videodecoder;
252 filter_collection_->SelectVideoDecoder(&old_videodecoder); 287 filter_collection_->SelectVideoDecoder(&old_videodecoder);
253 filter_collection_->AddVideoDecoder(new_decoder.get()); 288 filter_collection_->AddVideoDecoder(new_decoder.get());
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 void WebMediaPlayerImpl::OnPipelineInitialize(PipelineStatus status) { 736 void WebMediaPlayerImpl::OnPipelineInitialize(PipelineStatus status) {
702 DCHECK_EQ(main_loop_, MessageLoop::current()); 737 DCHECK_EQ(main_loop_, MessageLoop::current());
703 if (status == media::PIPELINE_OK) { 738 if (status == media::PIPELINE_OK) {
704 // Only keep one time range starting from 0. 739 // Only keep one time range starting from 0.
705 WebKit::WebTimeRanges new_buffered(static_cast<size_t>(1)); 740 WebKit::WebTimeRanges new_buffered(static_cast<size_t>(1));
706 new_buffered[0].start = 0.0f; 741 new_buffered[0].start = 0.0f;
707 new_buffered[0].end = 742 new_buffered[0].end =
708 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); 743 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF());
709 buffered_.swap(new_buffered); 744 buffered_.swap(new_buffered);
710 745
746 if (hasVideo()) {
747 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive",
748 is_accelerated_compositing_active_);
749 }
750
711 if (pipeline_->IsLoaded()) { 751 if (pipeline_->IsLoaded()) {
712 SetNetworkState(WebKit::WebMediaPlayer::Loaded); 752 SetNetworkState(WebKit::WebMediaPlayer::Loaded);
713 } 753 }
714 754
715 // Since we have initialized the pipeline, say we have everything otherwise 755 // Since we have initialized the pipeline, say we have everything otherwise
716 // we'll remain either loading/idle. 756 // we'll remain either loading/idle.
717 // TODO(hclam): change this to report the correct status. 757 // TODO(hclam): change this to report the correct status.
718 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); 758 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata);
719 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); 759 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
720 } else { 760 } else {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 return client_; 908 return client_;
869 } 909 }
870 910
871 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 911 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
872 DCHECK_EQ(main_loop_, MessageLoop::current()); 912 DCHECK_EQ(main_loop_, MessageLoop::current());
873 incremented_externally_allocated_memory_ = true; 913 incremented_externally_allocated_memory_ = true;
874 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 914 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
875 } 915 }
876 916
877 } // namespace webkit_glue 917 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698