From 2cd9d01be2194c4828307754c6f1334eb8bd7f57 Mon Sep 17 00:00:00 2001 From: mnaganov Date: Mon, 21 Sep 2015 15:54:29 -0700 Subject: [PATCH] [Android WebView] Put AndroidStreamReaderURLRequestJob into a namespace Put the class into android_webview ns, just like any other. Review URL: https://codereview.chromium.org/1356213003 Cr-Commit-Position: refs/heads/master@{#350055} --- .../browser/net/android_stream_reader_url_request_job.cc | 12 +++++++----- .../browser/net/android_stream_reader_url_request_job.h | 11 ++++++----- .../net/android_stream_reader_url_request_job_unittest.cc | 11 +++++++++-- android_webview/native/android_protocol_handler.cc | 1 + 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/android_webview/browser/net/android_stream_reader_url_request_job.cc b/android_webview/browser/net/android_stream_reader_url_request_job.cc index fd2691208efd..2f2d68428cd0 100644 --- a/android_webview/browser/net/android_stream_reader_url_request_job.cc +++ b/android_webview/browser/net/android_stream_reader_url_request_job.cc @@ -29,12 +29,12 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_job_manager.h" -using android_webview::InputStream; -using android_webview::InputStreamReader; using base::android::AttachCurrentThread; using base::PostTaskAndReplyWithResult; using content::BrowserThread; +namespace android_webview { + namespace { const int kHTTPOk = 200; @@ -63,7 +63,7 @@ class InputStreamReaderWrapper : DCHECK(input_stream_reader_); } - android_webview::InputStream* input_stream() { + InputStream* input_stream() { return input_stream_.get(); } @@ -79,8 +79,8 @@ class InputStreamReaderWrapper : friend class base::RefCountedThreadSafe; ~InputStreamReaderWrapper() {} - scoped_ptr input_stream_; - scoped_ptr input_stream_reader_; + scoped_ptr input_stream_; + scoped_ptr input_stream_reader_; DISALLOW_COPY_AND_ASSIGN(InputStreamReaderWrapper); }; @@ -365,3 +365,5 @@ void AndroidStreamReaderURLRequestJob::SetExtraRequestHeaders( } } } + +} // namespace android_webview diff --git a/android_webview/browser/net/android_stream_reader_url_request_job.h b/android_webview/browser/net/android_stream_reader_url_request_job.h index 903ba61c2850..e2049edc3b86 100644 --- a/android_webview/browser/net/android_stream_reader_url_request_job.h +++ b/android_webview/browser/net/android_stream_reader_url_request_job.h @@ -16,11 +16,6 @@ #include "net/http/http_byte_range.h" #include "net/url_request/url_request_job.h" -namespace android_webview { -class InputStream; -class InputStreamReader; -} - namespace base { class TaskRunner; } @@ -31,6 +26,10 @@ class HttpResponseInfo; class URLRequest; } +namespace android_webview { + +class InputStream; +class InputStreamReader; class InputStreamReaderWrapper; // A request job that reads data from a Java InputStream. @@ -120,4 +119,6 @@ class AndroidStreamReaderURLRequestJob : public net::URLRequestJob { DISALLOW_COPY_AND_ASSIGN(AndroidStreamReaderURLRequestJob); }; +} // namespace android_webview + #endif // ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ diff --git a/android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc b/android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc index 651d01d1e924..37416bafe6fb 100644 --- a/android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc +++ b/android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc @@ -22,8 +22,6 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -using android_webview::InputStream; -using android_webview::InputStreamReader; using net::TestDelegate; using net::TestJobInterceptor; using net::TestNetworkDelegate; @@ -45,6 +43,10 @@ using testing::WithArg; using testing::WithArgs; using testing::_; +namespace android_webview { + +namespace { + // Some of the classes will DCHECK on a null InputStream (which is desirable). // The workaround is to use this class. None of the methods need to be // implemented as the mock InputStreamReader should never forward calls to the @@ -179,6 +181,9 @@ class TestStreamReaderJob : public AndroidStreamReaderURLRequestJob { scoped_refptr task_runner_; }; +} // namespace + + class AndroidStreamReaderURLRequestJobTest : public Test { public: AndroidStreamReaderURLRequestJobTest() {} @@ -415,3 +420,5 @@ TEST_F(AndroidStreamReaderURLRequestJobTest, DeleteJobMidWayRead) { req_->Cancel(); EXPECT_EQ(1, network_delegate_.completed_requests()); } + +} // namespace android_webview diff --git a/android_webview/native/android_protocol_handler.cc b/android_webview/native/android_protocol_handler.cc index a2a9f6d38d7b..159534d4f02b 100644 --- a/android_webview/native/android_protocol_handler.cc +++ b/android_webview/native/android_protocol_handler.cc @@ -23,6 +23,7 @@ #include "url/gurl.h" #include "url/url_constants.h" +using android_webview::AndroidStreamReaderURLRequestJob; using android_webview::InputStream; using android_webview::InputStreamImpl; using base::android::AttachCurrentThread; -- 2.11.4.GIT