This source file includes following definitions.
- OpenInputStream
- OnInputStreamOpenFailed
- GetMimeType
- GetCharset
- CreateJobFor
#include "android_webview/browser/intercepted_request_data.h"
#include "android_webview/browser/input_stream.h"
#include "android_webview/browser/net/android_stream_reader_url_request_job.h"
namespace android_webview {
namespace {
class StreamReaderJobDelegateImpl
: public AndroidStreamReaderURLRequestJob::Delegate {
public:
StreamReaderJobDelegateImpl(
scoped_ptr<InterceptedRequestData> intercepted_request_data)
: intercepted_request_data_(intercepted_request_data.Pass()) {
DCHECK(intercepted_request_data_);
}
virtual scoped_ptr<InputStream> OpenInputStream(JNIEnv* env,
const GURL& url) OVERRIDE {
return intercepted_request_data_->GetInputStream(env).Pass();
}
virtual void OnInputStreamOpenFailed(net::URLRequest* request,
bool* restart) OVERRIDE {
*restart = false;
}
virtual bool GetMimeType(JNIEnv* env,
net::URLRequest* request,
android_webview::InputStream* stream,
std::string* mime_type) OVERRIDE {
return intercepted_request_data_->GetMimeType(env, mime_type);
}
virtual bool GetCharset(JNIEnv* env,
net::URLRequest* request,
android_webview::InputStream* stream,
std::string* charset) OVERRIDE {
return intercepted_request_data_->GetCharset(env, charset);
}
private:
scoped_ptr<InterceptedRequestData> intercepted_request_data_;
};
}
net::URLRequestJob* InterceptedRequestData::CreateJobFor(
scoped_ptr<InterceptedRequestData> intercepted_request_data,
net::URLRequest* request,
net::NetworkDelegate* network_delegate) {
DCHECK(intercepted_request_data);
DCHECK(request);
DCHECK(network_delegate);
return new AndroidStreamReaderURLRequestJob(
request,
network_delegate,
make_scoped_ptr(
new StreamReaderJobDelegateImpl(intercepted_request_data.Pass()))
.PassAs<AndroidStreamReaderURLRequestJob::Delegate>());
}
}