summaryrefslogtreecommitdiffstats
path: root/webkit/glue/media
diff options
context:
space:
mode:
authorscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 17:53:45 +0000
committerscottfr@chromium.org <scottfr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-09 17:53:45 +0000
commit24d75c714285a0c31b5e688a7c97fbc883e389c9 (patch)
treef908b22afc362f392ba02ac3a9a47175bca83a1d /webkit/glue/media
parent381455c05cb4f766d36cd99bb3fabde3e0d5246b (diff)
downloadchromium_src-24d75c714285a0c31b5e688a7c97fbc883e389c9.zip
chromium_src-24d75c714285a0c31b5e688a7c97fbc883e389c9.tar.gz
chromium_src-24d75c714285a0c31b5e688a7c97fbc883e389c9.tar.bz2
Log BufferedResourceLoader events to MediaLog.
BUG= TEST= Review URL: http://codereview.chromium.org/7591001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96014 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/media')
-rw-r--r--webkit/glue/media/buffered_data_source.cc20
-rw-r--r--webkit/glue/media/buffered_data_source.h10
-rw-r--r--webkit/glue/media/buffered_data_source_unittest.cc6
-rw-r--r--webkit/glue/media/buffered_resource_loader.cc19
-rw-r--r--webkit/glue/media/buffered_resource_loader.h12
-rw-r--r--webkit/glue/media/buffered_resource_loader_unittest.cc4
-rw-r--r--webkit/glue/media/simple_data_source.cc9
-rw-r--r--webkit/glue/media/simple_data_source.h5
-rw-r--r--webkit/glue/media/web_data_source_factory.cc11
-rw-r--r--webkit/glue/media/web_data_source_factory.h10
10 files changed, 85 insertions, 21 deletions
diff --git a/webkit/glue/media/buffered_data_source.cc b/webkit/glue/media/buffered_data_source.cc
index c125dd6..ce0ddce 100644
--- a/webkit/glue/media/buffered_data_source.cc
+++ b/webkit/glue/media/buffered_data_source.cc
@@ -5,6 +5,7 @@
#include "webkit/glue/media/buffered_data_source.h"
#include "media/base/filter_host.h"
+#include "media/base/media_log.h"
#include "net/base/net_errors.h"
#include "webkit/glue/media/web_data_source_factory.h"
#include "webkit/glue/webkit_glue.h"
@@ -23,22 +24,25 @@ static const int kInitialReadBufferSize = 32768;
static const int kNumCacheMissRetries = 3;
static WebDataSource* NewBufferedDataSource(MessageLoop* render_loop,
- WebKit::WebFrame* frame) {
- return new BufferedDataSource(render_loop, frame);
+ WebKit::WebFrame* frame,
+ media::MediaLog* media_log) {
+ return new BufferedDataSource(render_loop, frame, media_log);
}
// static
media::DataSourceFactory* BufferedDataSource::CreateFactory(
MessageLoop* render_loop,
WebKit::WebFrame* frame,
+ media::MediaLog* media_log,
WebDataSourceBuildObserverHack* build_observer) {
- return new WebDataSourceFactory(render_loop, frame, &NewBufferedDataSource,
- build_observer);
+ return new WebDataSourceFactory(render_loop, frame, media_log,
+ &NewBufferedDataSource, build_observer);
}
BufferedDataSource::BufferedDataSource(
MessageLoop* render_loop,
- WebFrame* frame)
+ WebFrame* frame,
+ media::MediaLog* media_log)
: total_bytes_(kPositionNotSpecified),
buffered_bytes_(0),
loaded_(false),
@@ -60,7 +64,8 @@ BufferedDataSource::BufferedDataSource(
media_has_played_(false),
preload_(media::METADATA),
using_range_request_(true),
- cache_miss_retries_left_(kNumCacheMissRetries) {
+ cache_miss_retries_left_(kNumCacheMissRetries),
+ media_log_(media_log) {
}
BufferedDataSource::~BufferedDataSource() {}
@@ -74,7 +79,8 @@ BufferedResourceLoader* BufferedDataSource::CreateResourceLoader(
return new BufferedResourceLoader(url_,
first_byte_position,
- last_byte_position);
+ last_byte_position,
+ media_log_);
}
void BufferedDataSource::set_host(media::FilterHost* host) {
diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h
index 408d095..2218c3d5 100644
--- a/webkit/glue/media/buffered_data_source.h
+++ b/webkit/glue/media/buffered_data_source.h
@@ -14,6 +14,10 @@
#include "media/base/filters.h"
#include "webkit/glue/media/buffered_resource_loader.h"
+namespace media {
+class MediaLog;
+}
+
namespace webkit_glue {
class BufferedDataSource : public WebDataSource {
@@ -22,10 +26,12 @@ class BufferedDataSource : public WebDataSource {
static media::DataSourceFactory* CreateFactory(
MessageLoop* render_loop,
WebKit::WebFrame* frame,
+ media::MediaLog* media_log,
WebDataSourceBuildObserverHack* build_observer);
BufferedDataSource(MessageLoop* render_loop,
- WebKit::WebFrame* frame);
+ WebKit::WebFrame* frame,
+ media::MediaLog* media_log);
virtual ~BufferedDataSource();
@@ -202,6 +208,8 @@ class BufferedDataSource : public WebDataSource {
// Number of cache miss retries left.
int cache_miss_retries_left_;
+ scoped_refptr<media::MediaLog> media_log_;
+
DISALLOW_COPY_AND_ASSIGN(BufferedDataSource);
};
diff --git a/webkit/glue/media/buffered_data_source_unittest.cc b/webkit/glue/media/buffered_data_source_unittest.cc
index 5cdde51..1a7dd7d 100644
--- a/webkit/glue/media/buffered_data_source_unittest.cc
+++ b/webkit/glue/media/buffered_data_source_unittest.cc
@@ -5,6 +5,7 @@
#include <algorithm>
#include "base/test/test_timeouts.h"
+#include "media/base/media_log.h"
#include "media/base/mock_callback.h"
#include "media/base/mock_filter_host.h"
#include "media/base/mock_filters.h"
@@ -50,7 +51,7 @@ enum NetworkState {
class MockBufferedDataSource : public BufferedDataSource {
public:
MockBufferedDataSource(MessageLoop* message_loop, WebFrame* frame)
- : BufferedDataSource(message_loop, frame) {
+ : BufferedDataSource(message_loop, frame, new media::MediaLog()) {
}
virtual base::TimeDelta GetTimeoutMilliseconds() {
@@ -68,7 +69,8 @@ class MockBufferedDataSource : public BufferedDataSource {
class MockBufferedResourceLoader : public BufferedResourceLoader {
public:
- MockBufferedResourceLoader() : BufferedResourceLoader(GURL(), 0, 0) {
+ MockBufferedResourceLoader()
+ : BufferedResourceLoader(GURL(), 0, 0, new media::MediaLog()) {
}
MOCK_METHOD3(Start, void(net::CompletionCallback* read_callback,
diff --git a/webkit/glue/media/buffered_resource_loader.cc b/webkit/glue/media/buffered_resource_loader.cc
index 6522726..7fbf181 100644
--- a/webkit/glue/media/buffered_resource_loader.cc
+++ b/webkit/glue/media/buffered_resource_loader.cc
@@ -7,6 +7,7 @@
#include "base/format_macros.h"
#include "base/stringprintf.h"
#include "base/string_util.h"
+#include "media/base/media_log.h"
#include "net/base/net_errors.h"
#include "net/http/http_request_headers.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
@@ -54,7 +55,8 @@ static const int kForwardWaitThreshold = 2 * kMegabyte;
BufferedResourceLoader::BufferedResourceLoader(
const GURL& url,
int64 first_byte_position,
- int64 last_byte_position)
+ int64 last_byte_position,
+ media::MediaLog* media_log)
: buffer_(new media::SeekableBuffer(kBackwardCapacity, kForwardCapacity)),
deferred_(false),
defer_strategy_(kReadThenDefer),
@@ -76,7 +78,8 @@ BufferedResourceLoader::BufferedResourceLoader(
read_buffer_(NULL),
first_offset_(0),
last_offset_(0),
- keep_test_loader_(false) {
+ keep_test_loader_(false),
+ media_log_(media_log) {
}
BufferedResourceLoader::~BufferedResourceLoader() {
@@ -399,6 +402,7 @@ void BufferedResourceLoader::didReceiveData(
// Notify that we have received some data.
NotifyNetworkEvent();
+ Log();
}
void BufferedResourceLoader::didDownloadData(
@@ -677,6 +681,7 @@ void BufferedResourceLoader::DoneRead(int error) {
read_buffer_ = NULL;
first_offset_ = 0;
last_offset_ = 0;
+ Log();
}
void BufferedResourceLoader::DoneStart(int error) {
@@ -693,4 +698,14 @@ bool BufferedResourceLoader::IsRangeRequest() const {
return first_byte_position_ != kPositionNotSpecified;
}
+void BufferedResourceLoader::Log() {
+ if (buffer_.get()) {
+ media_log_->AddEvent(
+ media_log_->CreateBufferedExtentsChangedEvent(
+ offset_ - buffer_->backward_bytes(),
+ offset_,
+ offset_ + buffer_->forward_bytes()));
+ }
+}
+
} // namespace webkit_glue
diff --git a/webkit/glue/media/buffered_resource_loader.h b/webkit/glue/media/buffered_resource_loader.h
index bdbb6a8..f1641bb 100644
--- a/webkit/glue/media/buffered_resource_loader.h
+++ b/webkit/glue/media/buffered_resource_loader.h
@@ -20,6 +20,10 @@
#include "webkit/glue/media/web_data_source.h"
#include "webkit/glue/webmediaplayer_impl.h"
+namespace media {
+class MediaLog;
+}
+
namespace webkit_glue {
const int64 kPositionNotSpecified = -1;
@@ -54,7 +58,8 @@ class BufferedResourceLoader
// |kPositionNotSpecified| for not specified.
BufferedResourceLoader(const GURL& url,
int64 first_byte_position,
- int64 last_byte_position);
+ int64 last_byte_position,
+ media::MediaLog* media_log);
// Start the resource loading with the specified URL and range.
// This method operates in asynchronous mode. Once there's a response from the
@@ -211,6 +216,9 @@ class BufferedResourceLoader
// Helper function that returns true if a range request was specified.
bool IsRangeRequest() const;
+ // Log everything interesting to |media_log_|.
+ void Log();
+
// A sliding window of buffer.
scoped_ptr<media::SeekableBuffer> buffer_;
@@ -264,6 +272,8 @@ class BufferedResourceLoader
// Used to ensure mocks for unittests are used instead of reset in Start().
bool keep_test_loader_;
+ scoped_refptr<media::MediaLog> media_log_;
+
DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader);
};
diff --git a/webkit/glue/media/buffered_resource_loader_unittest.cc b/webkit/glue/media/buffered_resource_loader_unittest.cc
index 034c1b3..d5056da6 100644
--- a/webkit/glue/media/buffered_resource_loader_unittest.cc
+++ b/webkit/glue/media/buffered_resource_loader_unittest.cc
@@ -7,6 +7,7 @@
#include "base/format_macros.h"
#include "base/stringprintf.h"
+#include "media/base/media_log.h"
#include "net/base/net_errors.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_util.h"
@@ -99,7 +100,8 @@ class BufferedResourceLoaderTest : public testing::Test {
url_loader_ = new NiceMock<MockWebURLLoader>();
loader_ = new BufferedResourceLoader(gurl_,
- first_position_, last_position_);
+ first_position_, last_position_,
+ new media::MediaLog());
loader_->SetURLLoaderForTest(url_loader_);
}
diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc
index 48c2044..ab9f6d6 100644
--- a/webkit/glue/media/simple_data_source.cc
+++ b/webkit/glue/media/simple_data_source.cc
@@ -7,6 +7,7 @@
#include "base/message_loop.h"
#include "base/process_util.h"
#include "media/base/filter_host.h"
+#include "media/base/media_log.h"
#include "net/base/data_url.h"
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
@@ -26,7 +27,8 @@ namespace webkit_glue {
static const char kDataScheme[] = "data";
static WebDataSource* NewSimpleDataSource(MessageLoop* render_loop,
- WebKit::WebFrame* frame) {
+ WebKit::WebFrame* frame,
+ media::MediaLog* media_log) {
return new SimpleDataSource(render_loop, frame);
}
@@ -34,9 +36,10 @@ static WebDataSource* NewSimpleDataSource(MessageLoop* render_loop,
media::DataSourceFactory* SimpleDataSource::CreateFactory(
MessageLoop* render_loop,
WebKit::WebFrame* frame,
+ media::MediaLog* media_log,
WebDataSourceBuildObserverHack* build_observer) {
- return new WebDataSourceFactory(render_loop, frame, &NewSimpleDataSource,
- build_observer);
+ return new WebDataSourceFactory(render_loop, frame, media_log,
+ &NewSimpleDataSource, build_observer);
}
SimpleDataSource::SimpleDataSource(
diff --git a/webkit/glue/media/simple_data_source.h b/webkit/glue/media/simple_data_source.h
index 721a8bad..ddb8f29 100644
--- a/webkit/glue/media/simple_data_source.h
+++ b/webkit/glue/media/simple_data_source.h
@@ -27,6 +27,10 @@
class MessageLoop;
class WebMediaPlayerDelegateImpl;
+namespace media {
+class MediaLog;
+}
+
namespace webkit_glue {
class SimpleDataSource
@@ -37,6 +41,7 @@ class SimpleDataSource
static media::DataSourceFactory* CreateFactory(
MessageLoop* render_loop,
WebKit::WebFrame* frame,
+ media::MediaLog* media_log,
WebDataSourceBuildObserverHack* build_observer);
SimpleDataSource(MessageLoop* render_loop, WebKit::WebFrame* frame);
diff --git a/webkit/glue/media/web_data_source_factory.cc b/webkit/glue/media/web_data_source_factory.cc
index d98e2da..070c0d0 100644
--- a/webkit/glue/media/web_data_source_factory.cc
+++ b/webkit/glue/media/web_data_source_factory.cc
@@ -5,6 +5,7 @@
#include "webkit/glue/media/web_data_source_factory.h"
#include "base/logging.h"
+#include "media/base/media_log.h"
namespace webkit_glue {
@@ -32,22 +33,25 @@ class WebDataSourceFactory::BuildRequest
WebDataSourceFactory::WebDataSourceFactory(
MessageLoop* render_loop,
WebKit::WebFrame* frame,
+ media::MediaLog* media_log,
FactoryFunction factory_function,
WebDataSourceBuildObserverHack* build_observer)
: render_loop_(render_loop),
frame_(frame),
+ media_log_(media_log),
factory_function_(factory_function),
build_observer_(build_observer) {
DCHECK(render_loop_);
DCHECK(frame_);
+ DCHECK(media_log_);
DCHECK(factory_function_);
}
WebDataSourceFactory::~WebDataSourceFactory() {}
media::DataSourceFactory* WebDataSourceFactory::Clone() const {
- return new WebDataSourceFactory(render_loop_, frame_, factory_function_,
- build_observer_);
+ return new WebDataSourceFactory(render_loop_, frame_, media_log_,
+ factory_function_, build_observer_);
}
bool WebDataSourceFactory::AllowRequests() const {
@@ -57,7 +61,8 @@ bool WebDataSourceFactory::AllowRequests() const {
media::AsyncDataSourceFactoryBase::BuildRequest*
WebDataSourceFactory::CreateRequest(const std::string& url,
BuildCallback* callback) {
- WebDataSource* data_source = factory_function_(render_loop_, frame_);
+ WebDataSource* data_source = factory_function_(render_loop_, frame_,
+ media_log_);
return new WebDataSourceFactory::BuildRequest(url, callback, data_source,
build_observer_);
diff --git a/webkit/glue/media/web_data_source_factory.h b/webkit/glue/media/web_data_source_factory.h
index 7163ef4..f685953 100644
--- a/webkit/glue/media/web_data_source_factory.h
+++ b/webkit/glue/media/web_data_source_factory.h
@@ -5,11 +5,16 @@
#ifndef WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_FACTORY_H_
#define WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_FACTORY_H_
+#include "base/memory/ref_counted.h"
#include "media/base/async_filter_factory_base.h"
#include "webkit/glue/media/web_data_source.h"
class MessageLoop;
+namespace media {
+class MediaLog;
+}
+
namespace WebKit {
class WebFrame;
}
@@ -19,9 +24,11 @@ namespace webkit_glue {
class WebDataSourceFactory : public media::AsyncDataSourceFactoryBase {
public:
typedef WebDataSource* (*FactoryFunction)(MessageLoop* render_loop,
- WebKit::WebFrame* frame);
+ WebKit::WebFrame* frame,
+ media::MediaLog* media_log);
WebDataSourceFactory(MessageLoop* render_loop, WebKit::WebFrame* frame,
+ media::MediaLog* media_log,
FactoryFunction factory_function,
WebDataSourceBuildObserverHack* build_observer);
virtual ~WebDataSourceFactory();
@@ -40,6 +47,7 @@ class WebDataSourceFactory : public media::AsyncDataSourceFactoryBase {
MessageLoop* render_loop_;
WebKit::WebFrame* frame_;
+ scoped_refptr<media::MediaLog> media_log_;
FactoryFunction factory_function_;
WebDataSourceBuildObserverHack* build_observer_;