summaryrefslogtreecommitdiffstats
path: root/media/base/composite_data_source_factory.cc
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 19:55:20 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 19:55:20 +0000
commita9415292f9aedca5c528532f1260118ad384aaed (patch)
treedf6dde3058efb3594a77ef78ce904c624f78da30 /media/base/composite_data_source_factory.cc
parentd2353452f11b73f763ea0be9f1a608d03cfddeac (diff)
downloadchromium_src-a9415292f9aedca5c528532f1260118ad384aaed.zip
chromium_src-a9415292f9aedca5c528532f1260118ad384aaed.tar.gz
chromium_src-a9415292f9aedca5c528532f1260118ad384aaed.tar.bz2
Replace DataSourceFactory with explicitly initialized DataSources.
BUG=107324 TEST=layout tests Review URL: https://chromiumcodereview.appspot.com/9243016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/composite_data_source_factory.cc')
-rw-r--r--media/base/composite_data_source_factory.cc98
1 files changed, 0 insertions, 98 deletions
diff --git a/media/base/composite_data_source_factory.cc b/media/base/composite_data_source_factory.cc
deleted file mode 100644
index e91415f..0000000
--- a/media/base/composite_data_source_factory.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2012 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.
-
-#include "media/base/composite_data_source_factory.h"
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/stl_util.h"
-
-namespace media {
-
-class CompositeDataSourceFactory::BuildRequest
- : public AsyncDataSourceFactoryBase::BuildRequest {
- public:
- BuildRequest(const std::string& url, const BuildCallback& callback,
- const FactoryList& factories);
- ~BuildRequest();
-
- protected:
- // AsyncDataSourceFactoryBase::BuildRequest method.
- virtual void DoStart();
-
- private:
- void CallNextFactory();
- void OnBuildDone(PipelineStatus status, DataSource* data_source);
-
- FactoryList factories_; // Not owned by this class.
-};
-
-CompositeDataSourceFactory::CompositeDataSourceFactory() {}
-
-CompositeDataSourceFactory::~CompositeDataSourceFactory() {
- STLDeleteElements(&factories_);
-}
-
-void CompositeDataSourceFactory::AddFactory(
- scoped_ptr<DataSourceFactory> factory) {
- DCHECK(factory.get());
- factories_.push_back(factory.release());
-}
-
-bool CompositeDataSourceFactory::AllowRequests() const {
- return !factories_.empty();
-}
-
-AsyncDataSourceFactoryBase::BuildRequest*
-CompositeDataSourceFactory::CreateRequest(const std::string& url,
- const BuildCallback& callback) {
- return new BuildRequest(url, callback, factories_);
-}
-
-CompositeDataSourceFactory::BuildRequest::BuildRequest(
- const std::string& url,
- const BuildCallback& callback,
- const FactoryList& factories)
- : AsyncDataSourceFactoryBase::BuildRequest(url, callback),
- factories_(factories){
- DCHECK(!factories.empty());
-}
-
-CompositeDataSourceFactory::BuildRequest::~BuildRequest() {}
-
-void CompositeDataSourceFactory::BuildRequest::DoStart() {
- CallNextFactory();
-}
-
-void CompositeDataSourceFactory::BuildRequest::CallNextFactory() {
- DCHECK(!factories_.empty());
-
- DataSourceFactory* factory = factories_.front();
- factories_.pop_front();
-
- factory->Build(url(), base::Bind(&BuildRequest::OnBuildDone,
- base::Unretained(this)));
-}
-
-void CompositeDataSourceFactory::BuildRequest::OnBuildDone(
- PipelineStatus status,
- DataSource* data_source) {
-
- if (status == PIPELINE_OK) {
- DCHECK(data_source);
- RequestComplete(status, data_source);
- return;
- }
-
- DCHECK(!data_source);
- if ((status == DATASOURCE_ERROR_URL_NOT_SUPPORTED) && !factories_.empty()) {
- CallNextFactory();
- return;
- }
-
- RequestComplete(status, data_source);
-}
-
-} // namespace media