#ifndef CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_
#define CONTENT_RENDERER_MEDIA_ANDROID_MEDIA_INFO_LOADER_H_
#include <string>
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "content/renderer/media/active_loader.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h"
#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
#include "url/gurl.h"
namespace blink {
class WebFrame;
class WebURLLoader;
class WebURLRequest;
}
namespace content {
class CONTENT_EXPORT MediaInfoLoader : private blink::WebURLLoaderClient {
public:
enum Status {
kFailed,
kOk,
};
typedef base::Callback<void(Status)> ReadyCB;
MediaInfoLoader(
const GURL& url,
blink::WebMediaPlayer::CORSMode cors_mode,
const ReadyCB& ready_cb);
virtual ~MediaInfoLoader();
void Start(blink::WebFrame* frame);
bool HasSingleOrigin() const;
bool DidPassCORSAccessCheck() const;
private:
friend class MediaInfoLoaderTest;
virtual void willSendRequest(
blink::WebURLLoader* loader,
blink::WebURLRequest& newRequest,
const blink::WebURLResponse& redirectResponse);
virtual void didSendData(
blink::WebURLLoader* loader,
unsigned long long bytesSent,
unsigned long long totalBytesToBeSent);
virtual void didReceiveResponse(
blink::WebURLLoader* loader,
const blink::WebURLResponse& response);
virtual void didDownloadData(
blink::WebURLLoader* loader,
int data_length,
int encodedDataLength);
virtual void didReceiveData(
blink::WebURLLoader* loader,
const char* data,
int data_length,
int encoded_data_length);
virtual void didReceiveCachedMetadata(
blink::WebURLLoader* loader,
const char* data, int dataLength);
virtual void didFinishLoading(
blink::WebURLLoader* loader,
double finishTime,
int64_t total_encoded_data_length);
virtual void didFail(
blink::WebURLLoader* loader,
const blink::WebURLError&);
void DidBecomeReady(Status status);
scoped_ptr<blink::WebURLLoader> test_loader_;
scoped_ptr<ActiveLoader> active_loader_;
bool loader_failed_;
GURL url_;
blink::WebMediaPlayer::CORSMode cors_mode_;
bool single_origin_;
ReadyCB ready_cb_;
base::TimeTicks start_time_;
DISALLOW_COPY_AND_ASSIGN(MediaInfoLoader);
};
}
#endif