Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: android_webview/browser/net/android_stream_reader_url_request_job.h

Issue 12531002: [android_webview] Make intercepted URLRequests have status codes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ 5 #ifndef ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_
6 #define ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ 6 #define ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_
7 7
8 #include <string>
9
8 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
9 #include "base/location.h" 11 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
13 #include "net/http/http_byte_range.h" 15 #include "net/http/http_byte_range.h"
14 #include "net/url_request/url_request_job.h" 16 #include "net/url_request/url_request_job.h"
15 17
16 namespace android_webview { 18 namespace android_webview {
17 class InputStream; 19 class InputStream;
18 class InputStreamReader; 20 class InputStreamReader;
19 } 21 }
20 22
21 namespace base { 23 namespace base {
22 class TaskRunner; 24 class TaskRunner;
23 } 25 }
24 26
25 namespace net { 27 namespace net {
28 class HttpResponseInfo;
26 class URLRequest; 29 class URLRequest;
27 } 30 }
28 31
29 class InputStreamReaderWrapper; 32 class InputStreamReaderWrapper;
30 33
31 // A request job that reads data from a Java InputStream. 34 // A request job that reads data from a Java InputStream.
32 class AndroidStreamReaderURLRequestJob : public net::URLRequestJob { 35 class AndroidStreamReaderURLRequestJob : public net::URLRequestJob {
33 public: 36 public:
34 /* 37 /*
35 * We use a delegate so that we can share code for this job in slightly 38 * We use a delegate so that we can share code for this job in slightly
(...skipping 28 matching lines...) Expand all
64 // URLRequestJob: 67 // URLRequestJob:
65 virtual void Start() OVERRIDE; 68 virtual void Start() OVERRIDE;
66 virtual void Kill() OVERRIDE; 69 virtual void Kill() OVERRIDE;
67 virtual bool ReadRawData(net::IOBuffer* buf, 70 virtual bool ReadRawData(net::IOBuffer* buf,
68 int buf_size, 71 int buf_size,
69 int* bytes_read) OVERRIDE; 72 int* bytes_read) OVERRIDE;
70 virtual void SetExtraRequestHeaders( 73 virtual void SetExtraRequestHeaders(
71 const net::HttpRequestHeaders& headers) OVERRIDE; 74 const net::HttpRequestHeaders& headers) OVERRIDE;
72 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; 75 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
73 virtual bool GetCharset(std::string* charset) OVERRIDE; 76 virtual bool GetCharset(std::string* charset) OVERRIDE;
77 virtual int GetResponseCode() const OVERRIDE;
78 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE;
74 79
75 protected: 80 protected:
76 virtual ~AndroidStreamReaderURLRequestJob(); 81 virtual ~AndroidStreamReaderURLRequestJob();
77 82
78 // Gets the TaskRunner for the worker thread. 83 // Gets the TaskRunner for the worker thread.
79 // Overridden in unittests. 84 // Overridden in unittests.
80 virtual base::TaskRunner* GetWorkerThreadRunner(); 85 virtual base::TaskRunner* GetWorkerThreadRunner();
81 86
82 // Creates an InputStreamReader instance. 87 // Creates an InputStreamReader instance.
83 // Overridden in unittests to return a mock. 88 // Overridden in unittests to return a mock.
84 virtual scoped_ptr<android_webview::InputStreamReader> 89 virtual scoped_ptr<android_webview::InputStreamReader>
85 CreateStreamReader(android_webview::InputStream* stream); 90 CreateStreamReader(android_webview::InputStream* stream);
86 91
87 private: 92 private:
88 void StartAsync(); 93 void StartAsync();
89 94
95 void HeadersComplete(int status_code, const std::string& status_text);
96
90 void OnReaderSeekCompleted(int content_size); 97 void OnReaderSeekCompleted(int content_size);
91 void OnReaderReadCompleted(int bytes_read); 98 void OnReaderReadCompleted(int bytes_read);
92 99
93 net::HttpByteRange byte_range_; 100 net::HttpByteRange byte_range_;
101 scoped_ptr<net::HttpResponseInfo> response_info_;
94 scoped_ptr<Delegate> delegate_; 102 scoped_ptr<Delegate> delegate_;
95 scoped_refptr<InputStreamReaderWrapper> input_stream_reader_wrapper_; 103 scoped_refptr<InputStreamReaderWrapper> input_stream_reader_wrapper_;
96 base::WeakPtrFactory<AndroidStreamReaderURLRequestJob> weak_factory_; 104 base::WeakPtrFactory<AndroidStreamReaderURLRequestJob> weak_factory_;
97 105
98 DISALLOW_COPY_AND_ASSIGN(AndroidStreamReaderURLRequestJob); 106 DISALLOW_COPY_AND_ASSIGN(AndroidStreamReaderURLRequestJob);
99 }; 107 };
100 108
101 #endif // ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ 109 #endif // ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698