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

Side by Side Diff: android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc

Issue 623833003: replace OVERRIDE and FINAL with override and final in android_webview/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 #include "android_webview/browser/input_stream.h" 5 #include "android_webview/browser/input_stream.h"
6 #include "android_webview/browser/net/android_stream_reader_url_request_job.h" 6 #include "android_webview/browser/net/android_stream_reader_url_request_job.h"
7 #include "android_webview/browser/net/aw_url_request_job_factory.h" 7 #include "android_webview/browser/net/aw_url_request_job_factory.h"
8 #include "android_webview/browser/net/input_stream_reader.h" 8 #include "android_webview/browser/net/input_stream_reader.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 using testing::_; 45 using testing::_;
46 46
47 // Some of the classes will DCHECK on a null InputStream (which is desirable). 47 // Some of the classes will DCHECK on a null InputStream (which is desirable).
48 // The workaround is to use this class. None of the methods need to be 48 // The workaround is to use this class. None of the methods need to be
49 // implemented as the mock InputStreamReader should never forward calls to the 49 // implemented as the mock InputStreamReader should never forward calls to the
50 // InputStream. 50 // InputStream.
51 class NotImplInputStream : public InputStream { 51 class NotImplInputStream : public InputStream {
52 public: 52 public:
53 NotImplInputStream() {} 53 NotImplInputStream() {}
54 virtual ~NotImplInputStream() {} 54 virtual ~NotImplInputStream() {}
55 virtual bool BytesAvailable(int* bytes_available) const OVERRIDE { 55 virtual bool BytesAvailable(int* bytes_available) const override {
56 NOTIMPLEMENTED(); 56 NOTIMPLEMENTED();
57 return false; 57 return false;
58 } 58 }
59 virtual bool Skip(int64_t n, int64_t* bytes_skipped) OVERRIDE { 59 virtual bool Skip(int64_t n, int64_t* bytes_skipped) override {
60 NOTIMPLEMENTED(); 60 NOTIMPLEMENTED();
61 return false; 61 return false;
62 } 62 }
63 virtual bool Read(net::IOBuffer* dest, int length, int* bytes_read) OVERRIDE { 63 virtual bool Read(net::IOBuffer* dest, int length, int* bytes_read) override {
64 NOTIMPLEMENTED(); 64 NOTIMPLEMENTED();
65 return false; 65 return false;
66 } 66 }
67 }; 67 };
68 68
69 // Required in order to create an instance of AndroidStreamReaderURLRequestJob. 69 // Required in order to create an instance of AndroidStreamReaderURLRequestJob.
70 class StreamReaderDelegate : 70 class StreamReaderDelegate :
71 public AndroidStreamReaderURLRequestJob::Delegate { 71 public AndroidStreamReaderURLRequestJob::Delegate {
72 public: 72 public:
73 StreamReaderDelegate() {} 73 StreamReaderDelegate() {}
74 74
75 virtual scoped_ptr<InputStream> OpenInputStream( 75 virtual scoped_ptr<InputStream> OpenInputStream(
76 JNIEnv* env, 76 JNIEnv* env,
77 const GURL& url) OVERRIDE { 77 const GURL& url) override {
78 return make_scoped_ptr<InputStream>(new NotImplInputStream()); 78 return make_scoped_ptr<InputStream>(new NotImplInputStream());
79 } 79 }
80 80
81 virtual void OnInputStreamOpenFailed(net::URLRequest* request, 81 virtual void OnInputStreamOpenFailed(net::URLRequest* request,
82 bool* restart) OVERRIDE { 82 bool* restart) override {
83 *restart = false; 83 *restart = false;
84 } 84 }
85 85
86 virtual bool GetMimeType(JNIEnv* env, 86 virtual bool GetMimeType(JNIEnv* env,
87 net::URLRequest* request, 87 net::URLRequest* request,
88 android_webview::InputStream* stream, 88 android_webview::InputStream* stream,
89 std::string* mime_type) OVERRIDE { 89 std::string* mime_type) override {
90 return false; 90 return false;
91 } 91 }
92 92
93 virtual bool GetCharset(JNIEnv* env, 93 virtual bool GetCharset(JNIEnv* env,
94 net::URLRequest* request, 94 net::URLRequest* request,
95 android_webview::InputStream* stream, 95 android_webview::InputStream* stream,
96 std::string* charset) OVERRIDE { 96 std::string* charset) override {
97 return false; 97 return false;
98 } 98 }
99 99
100 virtual void AppendResponseHeaders( 100 virtual void AppendResponseHeaders(
101 JNIEnv* env, 101 JNIEnv* env,
102 net::HttpResponseHeaders* headers) OVERRIDE { 102 net::HttpResponseHeaders* headers) override {
103 // no-op 103 // no-op
104 } 104 }
105 }; 105 };
106 106
107 class NullStreamReaderDelegate : public StreamReaderDelegate { 107 class NullStreamReaderDelegate : public StreamReaderDelegate {
108 public: 108 public:
109 NullStreamReaderDelegate() {} 109 NullStreamReaderDelegate() {}
110 110
111 virtual scoped_ptr<InputStream> OpenInputStream( 111 virtual scoped_ptr<InputStream> OpenInputStream(
112 JNIEnv* env, 112 JNIEnv* env,
113 const GURL& url) OVERRIDE { 113 const GURL& url) override {
114 return make_scoped_ptr<InputStream>(NULL); 114 return make_scoped_ptr<InputStream>(NULL);
115 } 115 }
116 }; 116 };
117 117
118 class HeaderAlteringStreamReaderDelegate : public NullStreamReaderDelegate { 118 class HeaderAlteringStreamReaderDelegate : public NullStreamReaderDelegate {
119 public: 119 public:
120 HeaderAlteringStreamReaderDelegate() {} 120 HeaderAlteringStreamReaderDelegate() {}
121 121
122 virtual void AppendResponseHeaders( 122 virtual void AppendResponseHeaders(
123 JNIEnv* env, 123 JNIEnv* env,
124 net::HttpResponseHeaders* headers) OVERRIDE { 124 net::HttpResponseHeaders* headers) override {
125 headers->ReplaceStatusLine(kStatusLine); 125 headers->ReplaceStatusLine(kStatusLine);
126 std::string headerLine(kCustomHeaderName); 126 std::string headerLine(kCustomHeaderName);
127 headerLine.append(": "); 127 headerLine.append(": ");
128 headerLine.append(kCustomHeaderValue); 128 headerLine.append(kCustomHeaderValue);
129 headers->AddHeader(headerLine); 129 headers->AddHeader(headerLine);
130 } 130 }
131 131
132 static const int kResponseCode; 132 static const int kResponseCode;
133 static const char* kStatusLine; 133 static const char* kStatusLine;
134 static const char* kCustomHeaderName; 134 static const char* kCustomHeaderName;
(...skipping 26 matching lines...) Expand all
161 scoped_ptr<Delegate> delegate, 161 scoped_ptr<Delegate> delegate,
162 scoped_ptr<InputStreamReader> stream_reader) 162 scoped_ptr<InputStreamReader> stream_reader)
163 : AndroidStreamReaderURLRequestJob(request, 163 : AndroidStreamReaderURLRequestJob(request,
164 network_delegate, 164 network_delegate,
165 delegate.Pass()), 165 delegate.Pass()),
166 stream_reader_(stream_reader.Pass()) { 166 stream_reader_(stream_reader.Pass()) {
167 message_loop_proxy_ = base::MessageLoopProxy::current(); 167 message_loop_proxy_ = base::MessageLoopProxy::current();
168 } 168 }
169 169
170 virtual scoped_ptr<InputStreamReader> CreateStreamReader( 170 virtual scoped_ptr<InputStreamReader> CreateStreamReader(
171 InputStream* stream) OVERRIDE { 171 InputStream* stream) override {
172 return stream_reader_.Pass(); 172 return stream_reader_.Pass();
173 } 173 }
174 protected: 174 protected:
175 virtual ~TestStreamReaderJob() {} 175 virtual ~TestStreamReaderJob() {}
176 176
177 virtual base::TaskRunner* GetWorkerThreadRunner() OVERRIDE { 177 virtual base::TaskRunner* GetWorkerThreadRunner() override {
178 return message_loop_proxy_.get(); 178 return message_loop_proxy_.get();
179 } 179 }
180 180
181 scoped_ptr<InputStreamReader> stream_reader_; 181 scoped_ptr<InputStreamReader> stream_reader_;
182 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 182 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
183 }; 183 };
184 184
185 class AndroidStreamReaderURLRequestJobTest : public Test { 185 class AndroidStreamReaderURLRequestJobTest : public Test {
186 public: 186 public:
187 AndroidStreamReaderURLRequestJobTest() {} 187 AndroidStreamReaderURLRequestJobTest() {}
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 414
415 SetRange(req_.get(), offset, bytes_available); 415 SetRange(req_.get(), offset, bytes_available);
416 req_->Start(); 416 req_->Start();
417 417
418 loop.Run(); 418 loop.Run();
419 419
420 EXPECT_EQ(0, network_delegate_.completed_requests()); 420 EXPECT_EQ(0, network_delegate_.completed_requests());
421 req_->Cancel(); 421 req_->Cancel();
422 EXPECT_EQ(1, network_delegate_.completed_requests()); 422 EXPECT_EQ(1, network_delegate_.completed_requests());
423 } 423 }
OLDNEW
« no previous file with comments | « android_webview/browser/net/android_stream_reader_url_request_job.h ('k') | android_webview/browser/net/aw_network_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698