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

Unified Diff: android_webview/native/android_protocol_handler.cc

Issue 11293252: Change Interceptors into URLRequestJobFactory::ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address erikwright's third round of comments Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/native/android_protocol_handler.cc
diff --git a/android_webview/native/android_protocol_handler.cc b/android_webview/native/android_protocol_handler.cc
index fb7283a723b2053ee141d3f62da8e89068c88235..37f9cdf02cc3920cfe2d6a568205e1fd192fbfe0 100644
--- a/android_webview/native/android_protocol_handler.cc
+++ b/android_webview/native/android_protocol_handler.cc
@@ -19,6 +19,7 @@
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/http/http_util.h"
+#include "net/url_request/protocol_intercept_job_factory.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_job_factory.h"
@@ -66,22 +67,17 @@ class AndroidStreamReaderURLRequestJobDelegateImpl
};
class AssetFileProtocolInterceptor :
- public net::URLRequestJobFactory::Interceptor {
+ public net::URLRequestJobFactory::ProtocolHandler {
public:
- AssetFileProtocolInterceptor();
+ static scoped_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
+ scoped_ptr<net::URLRequestJobFactory> base_job_factory);
virtual ~AssetFileProtocolInterceptor() OVERRIDE;
- virtual net::URLRequestJob* MaybeIntercept(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE;
- virtual net::URLRequestJob* MaybeInterceptRedirect(
- const GURL& location,
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE;
- virtual net::URLRequestJob* MaybeInterceptResponse(
+ virtual net::URLRequestJob* MaybeCreateJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const OVERRIDE;
private:
+ AssetFileProtocolInterceptor();
// file:///android_asset/
const std::string asset_prefix_;
// file:///android_res/
@@ -196,7 +192,17 @@ AssetFileProtocolInterceptor::AssetFileProtocolInterceptor()
AssetFileProtocolInterceptor::~AssetFileProtocolInterceptor() {
}
-net::URLRequestJob* AssetFileProtocolInterceptor::MaybeIntercept(
+// static
+scoped_ptr<net::URLRequestJobFactory>
+AssetFileProtocolInterceptor::CreateURLRequestJobFactory(
+ scoped_ptr<net::URLRequestJobFactory> base_job_factory) {
+ scoped_ptr<net::URLRequestJobFactory> top_job_factory(
+ new net::ProtocolInterceptJobFactory(base_job_factory.Pass(),
+ new AssetFileProtocolInterceptor()));
+ return top_job_factory.Pass();
+}
+
+net::URLRequestJob* AssetFileProtocolInterceptor::MaybeCreateJob(
net::URLRequest* request, net::NetworkDelegate* network_delegate) const {
if (!request->url().SchemeIsFile()) return NULL;
@@ -213,19 +219,6 @@ net::URLRequestJob* AssetFileProtocolInterceptor::MaybeIntercept(
new AndroidStreamReaderURLRequestJobDelegateImpl()));
}
-net::URLRequestJob* AssetFileProtocolInterceptor::MaybeInterceptRedirect(
- const GURL& location,
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const {
- return NULL;
-}
-
-net::URLRequestJob* AssetFileProtocolInterceptor::MaybeInterceptResponse(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const {
- return NULL;
-}
-
} // namespace
namespace android_webview {
@@ -235,9 +228,9 @@ bool RegisterAndroidProtocolHandler(JNIEnv* env) {
}
// static
-void RegisterAndroidProtocolsOnIOThread(
+scoped_ptr<net::URLRequestJobFactory> RegisterAndroidProtocolsOnIOThread(
mmenke 2012/12/11 17:22:38 Since we're creating a new factory, I think this f
net::URLRequestContext* context,
mmenke 2012/12/11 17:22:38 While we're here, looks like we don't need |contex
- net::URLRequestJobFactory* job_factory) {
+ scoped_ptr<net::URLRequestJobFactory> job_factory) {
// Register content://. Note that even though a scheme is
// registered here, it cannot be used by child processes until access to it is
// granted via ChildProcessSecurityPolicy::GrantScheme(). This is done in
@@ -245,8 +238,8 @@ void RegisterAndroidProtocolsOnIOThread(
// The job factory takes ownership of the handler.
job_factory->SetProtocolHandler(android_webview::kContentScheme,
new ContentSchemeProtocolHandler());
- // The job factory takes ownership of the interceptor.
- job_factory->AddInterceptor(new AssetFileProtocolInterceptor());
+ return AssetFileProtocolInterceptor::CreateURLRequestJobFactory(
+ job_factory.Pass());
}
// Set a context object to be used for resolving resource queries. This can

Powered by Google App Engine
This is Rietveld 408576698