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

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: . 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 // Helper enum for reporting scheme histograms.
242 enum URLSchemeForHistogram {
tony 2011/11/15 20:50:54 Nit: Can we put this in the anonymous namespace?
Ami GONE FROM CHROMIUM 2011/11/15 21:03:53 I prefer to keep this near the (only) site of use,
tony 2011/11/15 21:33:21 Style guide says to put it in an anonymous namespa
Ami GONE FROM CHROMIUM 2011/11/15 21:47:35 Ok, but under protest. The justification in the
243 kUnknownURLScheme,
244 kMissingURLScheme,
245 kHttpURLScheme,
246 kHttpsURLScheme,
247 kFtpURLScheme,
248 kChromeExtensionURLScheme,
249 kJavascriptURLScheme,
250 kFileURLScheme,
251 kBlobURLScheme,
252 kDataURLScheme,
253 kMaxURLScheme = kDataURLScheme // Must be equal to highest enum value.
254 };
255
256 static URLSchemeForHistogram URLScheme(const GURL& url) {
tony 2011/11/15 20:50:54 Nit: This could also go in the anonymous namespace
Ami GONE FROM CHROMIUM 2011/11/15 21:03:53 Ditto. (plus anonymous namespaces are generally le
257 if (!url.has_scheme()) return kMissingURLScheme;
258 if (url.SchemeIs("http")) return kHttpURLScheme;
259 if (url.SchemeIs("https")) return kHttpsURLScheme;
260 if (url.SchemeIs("ftp")) return kFtpURLScheme;
261 if (url.SchemeIs("chrome-extension")) return kChromeExtensionURLScheme;
262 if (url.SchemeIs("javascript")) return kJavascriptURLScheme;
263 if (url.SchemeIs("file")) return kFileURLScheme;
264 if (url.SchemeIs("blob")) return kBlobURLScheme;
265 if (url.SchemeIs("data")) return kDataURLScheme;
tony 2011/11/15 20:50:54 Nit: You could just make an array of char* pointer
Ami GONE FROM CHROMIUM 2011/11/15 21:03:53 I started out really liking this suggestion, and c
tony 2011/11/15 21:33:21 You could avoid some of the ickiness by doing: sta
266 return kUnknownURLScheme;
267 }
268
240 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { 269 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) {
241 DCHECK_EQ(main_loop_, MessageLoop::current()); 270 DCHECK_EQ(main_loop_, MessageLoop::current());
242 DCHECK(proxy_); 271 DCHECK(proxy_);
243 272
273 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(url), kMaxURLScheme);
274
244 if (media_stream_client_) { 275 if (media_stream_client_) {
245 bool has_video = false; 276 bool has_video = false;
246 bool has_audio = false; 277 bool has_audio = false;
247 scoped_refptr<media::VideoDecoder> new_decoder = 278 scoped_refptr<media::VideoDecoder> new_decoder =
248 media_stream_client_->GetVideoDecoder(url, message_loop_factory_.get()); 279 media_stream_client_->GetVideoDecoder(url, message_loop_factory_.get());
249 if (new_decoder.get()) { 280 if (new_decoder.get()) {
250 // Remove the default decoder. 281 // Remove the default decoder.
251 scoped_refptr<media::VideoDecoder> old_videodecoder; 282 scoped_refptr<media::VideoDecoder> old_videodecoder;
252 filter_collection_->SelectVideoDecoder(&old_videodecoder); 283 filter_collection_->SelectVideoDecoder(&old_videodecoder);
253 filter_collection_->AddVideoDecoder(new_decoder.get()); 284 filter_collection_->AddVideoDecoder(new_decoder.get());
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 void WebMediaPlayerImpl::OnPipelineInitialize(PipelineStatus status) { 732 void WebMediaPlayerImpl::OnPipelineInitialize(PipelineStatus status) {
702 DCHECK_EQ(main_loop_, MessageLoop::current()); 733 DCHECK_EQ(main_loop_, MessageLoop::current());
703 if (status == media::PIPELINE_OK) { 734 if (status == media::PIPELINE_OK) {
704 // Only keep one time range starting from 0. 735 // Only keep one time range starting from 0.
705 WebKit::WebTimeRanges new_buffered(static_cast<size_t>(1)); 736 WebKit::WebTimeRanges new_buffered(static_cast<size_t>(1));
706 new_buffered[0].start = 0.0f; 737 new_buffered[0].start = 0.0f;
707 new_buffered[0].end = 738 new_buffered[0].end =
708 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF()); 739 static_cast<float>(pipeline_->GetMediaDuration().InSecondsF());
709 buffered_.swap(new_buffered); 740 buffered_.swap(new_buffered);
710 741
742 if (hasVideo()) {
743 UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive",
744 is_accelerated_compositing_active_);
745 }
746
711 if (pipeline_->IsLoaded()) { 747 if (pipeline_->IsLoaded()) {
712 SetNetworkState(WebKit::WebMediaPlayer::Loaded); 748 SetNetworkState(WebKit::WebMediaPlayer::Loaded);
713 } 749 }
714 750
715 // Since we have initialized the pipeline, say we have everything otherwise 751 // Since we have initialized the pipeline, say we have everything otherwise
716 // we'll remain either loading/idle. 752 // we'll remain either loading/idle.
717 // TODO(hclam): change this to report the correct status. 753 // TODO(hclam): change this to report the correct status.
718 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata); 754 SetReadyState(WebKit::WebMediaPlayer::HaveMetadata);
719 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData); 755 SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
720 } else { 756 } else {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 return client_; 904 return client_;
869 } 905 }
870 906
871 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 907 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
872 DCHECK_EQ(main_loop_, MessageLoop::current()); 908 DCHECK_EQ(main_loop_, MessageLoop::current());
873 incremented_externally_allocated_memory_ = true; 909 incremented_externally_allocated_memory_ = true;
874 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 910 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
875 } 911 }
876 912
877 } // namespace webkit_glue 913 } // 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