Commit a5081a4c authored by acolwell's avatar acolwell Committed by Commit bot

Move Preload enum to BufferedDataSource.

Moving the Preload out of the content namespace and into BufferedDataSource
since that class is the primary reason this enum exists.

BUG=408338

Review URL: https://codereview.chromium.org/512413002

Cr-Commit-Position: refs/heads/master@{#292503}
parent 1eabd492
......@@ -282,7 +282,6 @@
'renderer/media/midi_dispatcher.h',
'renderer/media/midi_message_filter.cc',
'renderer/media/midi_message_filter.h',
'renderer/media/preload.h',
'renderer/media/render_media_log.cc',
'renderer/media/render_media_log.h',
'renderer/media/renderer_gpu_video_accelerator_factories.cc',
......
......@@ -12,7 +12,6 @@
#include "base/synchronization/lock.h"
#include "content/common/content_export.h"
#include "content/renderer/media/buffered_resource_loader.h"
#include "content/renderer/media/preload.h"
#include "media/base/data_source.h"
#include "media/base/ranges.h"
#include "url/gurl.h"
......@@ -48,6 +47,18 @@ class CONTENT_EXPORT BufferedDataSourceHost {
// before being passed to other threads. It may be deleted on any thread.
class CONTENT_EXPORT BufferedDataSource : public media::DataSource {
public:
// Used to specify video preload states. They are "hints" to the browser about
// how aggressively the browser should load and buffer data.
// Please see the HTML5 spec for the descriptions of these values:
// http://www.w3.org/TR/html5/video.html#attr-media-preload
//
// Enum values must match the values in blink::WebMediaPlayer::Preload and
// there will be assertions at compile time if they do not match.
enum Preload {
NONE,
METADATA,
AUTO,
};
typedef base::Callback<void(bool)> DownloadingCB;
// |url| and |cors_mode| are passed to the object. Buffered byte range changes
......
......@@ -112,7 +112,7 @@ class BufferedDataSourceTest : public testing::Test {
BufferedDataSourceTest()
: view_(WebView::create(NULL)),
frame_(WebLocalFrame::create(&client_)),
preload_(AUTO) {
preload_(BufferedDataSource::AUTO) {
view_->setMainFrame(frame_);
}
......@@ -225,8 +225,8 @@ class BufferedDataSourceTest : public testing::Test {
return loader()->active_loader_->loader_.get();
}
Preload preload() { return data_source_->preload_; }
void set_preload(Preload preload) { preload_ = preload; }
BufferedDataSource::Preload preload() { return data_source_->preload_; }
void set_preload(BufferedDataSource::Preload preload) { preload_ = preload; }
BufferedResourceLoader::DeferStrategy defer_strategy() {
return loader()->defer_strategy_;
}
......@@ -253,7 +253,7 @@ class BufferedDataSourceTest : public testing::Test {
// Used for calling BufferedDataSource::Read().
uint8 buffer_[kDataSize];
Preload preload_;
BufferedDataSource::Preload preload_;
DISALLOW_COPY_AND_ASSIGN(BufferedDataSourceTest);
};
......@@ -525,7 +525,7 @@ TEST_F(BufferedDataSourceTest, DefaultValues) {
InitializeWith206Response();
// Ensure we have sane values for default loading scenario.
EXPECT_EQ(AUTO, preload());
EXPECT_EQ(BufferedDataSource::AUTO, preload());
EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy());
EXPECT_EQ(0, data_source_bitrate());
......@@ -663,7 +663,7 @@ TEST_F(BufferedDataSourceTest, File_FinishLoading) {
TEST_F(BufferedDataSourceTest, LocalResource_DeferStrategy) {
InitializeWithFileResponse();
EXPECT_EQ(AUTO, preload());
EXPECT_EQ(BufferedDataSource::AUTO, preload());
EXPECT_TRUE(is_local_source());
EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy());
......@@ -677,10 +677,10 @@ TEST_F(BufferedDataSourceTest, LocalResource_DeferStrategy) {
}
TEST_F(BufferedDataSourceTest, LocalResource_PreloadMetadata_DeferStrategy) {
set_preload(METADATA);
set_preload(BufferedDataSource::METADATA);
InitializeWithFileResponse();
EXPECT_EQ(METADATA, preload());
EXPECT_EQ(BufferedDataSource::METADATA, preload());
EXPECT_TRUE(is_local_source());
EXPECT_EQ(BufferedResourceLoader::kReadThenDefer, defer_strategy());
......@@ -696,7 +696,7 @@ TEST_F(BufferedDataSourceTest, LocalResource_PreloadMetadata_DeferStrategy) {
TEST_F(BufferedDataSourceTest, ExternalResource_Reponse200_DeferStrategy) {
InitializeWith200Response();
EXPECT_EQ(AUTO, preload());
EXPECT_EQ(BufferedDataSource::AUTO, preload());
EXPECT_FALSE(is_local_source());
EXPECT_FALSE(loader()->range_supported());
EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy());
......@@ -712,10 +712,10 @@ TEST_F(BufferedDataSourceTest, ExternalResource_Reponse200_DeferStrategy) {
TEST_F(BufferedDataSourceTest,
ExternalResource_Response200_PreloadMetadata_DeferStrategy) {
set_preload(METADATA);
set_preload(BufferedDataSource::METADATA);
InitializeWith200Response();
EXPECT_EQ(METADATA, preload());
EXPECT_EQ(BufferedDataSource::METADATA, preload());
EXPECT_FALSE(is_local_source());
EXPECT_FALSE(loader()->range_supported());
EXPECT_EQ(BufferedResourceLoader::kReadThenDefer, defer_strategy());
......@@ -732,7 +732,7 @@ TEST_F(BufferedDataSourceTest,
TEST_F(BufferedDataSourceTest, ExternalResource_Reponse206_DeferStrategy) {
InitializeWith206Response();
EXPECT_EQ(AUTO, preload());
EXPECT_EQ(BufferedDataSource::AUTO, preload());
EXPECT_FALSE(is_local_source());
EXPECT_TRUE(loader()->range_supported());
EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy());
......@@ -754,10 +754,10 @@ TEST_F(BufferedDataSourceTest, ExternalResource_Reponse206_DeferStrategy) {
TEST_F(BufferedDataSourceTest,
ExternalResource_Response206_PreloadMetadata_DeferStrategy) {
set_preload(METADATA);
set_preload(BufferedDataSource::METADATA);
InitializeWith206Response();
EXPECT_EQ(METADATA, preload());
EXPECT_EQ(BufferedDataSource::METADATA, preload());
EXPECT_FALSE(is_local_source());
EXPECT_TRUE(loader()->range_supported());
EXPECT_EQ(BufferedResourceLoader::kReadThenDefer, defer_strategy());
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_MEDIA_PRELOAD_H_
#define CONTENT_RENDERER_MEDIA_PRELOAD_H_
namespace content {
// Used to specify video preload states. They are "hints" to the browser about
// how aggressively the browser should load and buffer data.
// Please see the HTML5 spec for the descriptions of these values:
// http://www.w3.org/TR/html5/video.html#attr-media-preload
//
// Enum values must match the values in WebCore::MediaPlayer::Preload and
// there will be assertions at compile time if they do not match.
enum Preload {
NONE,
METADATA,
AUTO,
};
} // namespace content
#endif // CONTENT_RENDERER_MEDIA_PRELOAD_H_
......@@ -148,7 +148,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
: frame_(frame),
network_state_(WebMediaPlayer::NetworkStateEmpty),
ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
preload_(AUTO),
preload_(BufferedDataSource::AUTO),
main_task_runner_(base::MessageLoopProxy::current()),
media_task_runner_(
RenderThreadImpl::current()->GetMediaThreadTaskRunner()),
......@@ -380,7 +380,7 @@ void WebMediaPlayerImpl::setVolume(double volume) {
#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \
COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::webkit_name) == \
static_cast<int>(content::chromium_name), \
static_cast<int>(BufferedDataSource::chromium_name), \
mismatching_enums)
COMPILE_ASSERT_MATCHING_ENUM(PreloadNone, NONE);
COMPILE_ASSERT_MATCHING_ENUM(PreloadMetaData, METADATA);
......@@ -391,7 +391,7 @@ void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) {
DVLOG(1) << __FUNCTION__ << "(" << preload << ")";
DCHECK(main_task_runner_->BelongsToCurrentThread());
preload_ = static_cast<content::Preload>(preload);
preload_ = static_cast<BufferedDataSource::Preload>(preload);
if (data_source_)
data_source_->SetPreload(preload_);
}
......
......@@ -228,7 +228,7 @@ class WebMediaPlayerImpl
blink::WebMediaPlayer::ReadyState ready_state_;
// Preload state for when |data_source_| is created after setPreload().
content::Preload preload_;
BufferedDataSource::Preload preload_;
// Task runner for posting tasks on Chrome's main thread. Also used
// for DCHECKs so methods calls won't execute in the wrong thread.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment