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
3// found in the LICENSE file.
4
5#ifndef WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_FACTORY_H_
6#define WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_FACTORY_H_
7
8#include "media/base/async_filter_factory_base.h"
9#include "webkit/glue/media/web_data_source.h"
10
11class MessageLoop;
12
13namespace WebKit {
14class WebFrame;
15}
16
17namespace webkit_glue {
18
19class WebDataSourceFactory : public media::AsyncDataSourceFactoryBase {
20 public:
21  typedef WebDataSource* (*FactoryFunction)(MessageLoop* render_loop,
22                                            WebKit::WebFrame* frame);
23
24  WebDataSourceFactory(MessageLoop* render_loop, WebKit::WebFrame* frame,
25                       FactoryFunction factory_function,
26                       WebDataSourceBuildObserverHack* build_observer);
27  virtual ~WebDataSourceFactory();
28
29  // DataSourceFactory method.
30  virtual media::DataSourceFactory* Clone() const;
31
32 protected:
33  // AsyncDataSourceFactoryBase methods.
34  virtual bool AllowRequests() const;
35  virtual AsyncDataSourceFactoryBase::BuildRequest* CreateRequest(
36      const std::string& url, BuildCallback* callback);
37
38 private:
39  class BuildRequest;
40
41  MessageLoop* render_loop_;
42  WebKit::WebFrame* frame_;
43  FactoryFunction factory_function_;
44  WebDataSourceBuildObserverHack* build_observer_;
45
46  DISALLOW_COPY_AND_ASSIGN(WebDataSourceFactory);
47};
48
49}  // namespace webkit_glue
50
51#endif  // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_FACTORY_H_
52