Send compressed histograms with system logs when sending feedback.
[chromium-blink-merge.git] / android_webview / browser / intercepted_request_data.cc
blob6e25ce14474fbff9d4389581e6de9c0d21251abf
1 // Copyright 2013 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.
5 #include "android_webview/browser/intercepted_request_data.h"
7 #include "android_webview/browser/input_stream.h"
8 #include "android_webview/browser/net/android_stream_reader_url_request_job.h"
10 namespace android_webview {
12 namespace {
14 class StreamReaderJobDelegateImpl
15 : public AndroidStreamReaderURLRequestJob::Delegate {
16 public:
17 StreamReaderJobDelegateImpl(
18 scoped_ptr<InterceptedRequestData> intercepted_request_data)
19 : intercepted_request_data_(intercepted_request_data.Pass()) {
20 DCHECK(intercepted_request_data_);
23 virtual scoped_ptr<InputStream> OpenInputStream(JNIEnv* env,
24 const GURL& url) OVERRIDE {
25 return intercepted_request_data_->GetInputStream(env).Pass();
28 virtual void OnInputStreamOpenFailed(net::URLRequest* request,
29 bool* restart) OVERRIDE {
30 *restart = false;
33 virtual bool GetMimeType(JNIEnv* env,
34 net::URLRequest* request,
35 android_webview::InputStream* stream,
36 std::string* mime_type) OVERRIDE {
37 return intercepted_request_data_->GetMimeType(env, mime_type);
40 virtual bool GetCharset(JNIEnv* env,
41 net::URLRequest* request,
42 android_webview::InputStream* stream,
43 std::string* charset) OVERRIDE {
44 return intercepted_request_data_->GetCharset(env, charset);
47 private:
48 scoped_ptr<InterceptedRequestData> intercepted_request_data_;
51 } // namespace
53 // static
54 net::URLRequestJob* InterceptedRequestData::CreateJobFor(
55 scoped_ptr<InterceptedRequestData> intercepted_request_data,
56 net::URLRequest* request,
57 net::NetworkDelegate* network_delegate) {
58 DCHECK(intercepted_request_data);
59 DCHECK(request);
60 DCHECK(network_delegate);
62 return new AndroidStreamReaderURLRequestJob(
63 request,
64 network_delegate,
65 make_scoped_ptr(
66 new StreamReaderJobDelegateImpl(intercepted_request_data.Pass()))
67 .PassAs<AndroidStreamReaderURLRequestJob::Delegate>());
70 } // namespace android_webview