| Index: chrome/browser/net/chrome_url_request_context.cc
|
| diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
|
| index 6b8bbc803dab9db0c6e11b00cfee894183238334..6f8b86a3f531e88c742d5cd90edc5eccd4cd5909 100644
|
| --- a/chrome/browser/net/chrome_url_request_context.cc
|
| +++ b/chrome/browser/net/chrome_url_request_context.cc
|
| @@ -76,15 +76,23 @@ class FactoryForIsolatedApp : public ChromeURLRequestContextFactory {
|
| public:
|
| FactoryForIsolatedApp(const ProfileIOData* profile_io_data,
|
| const std::string& app_id,
|
| - ChromeURLRequestContextGetter* main_context)
|
| + ChromeURLRequestContextGetter* main_context,
|
| + scoped_ptr<net::URLRequestJobFactory::Interceptor>
|
| + protocol_handler_interceptor)
|
| : profile_io_data_(profile_io_data),
|
| app_id_(app_id),
|
| - main_request_context_getter_(main_context) {}
|
| + main_request_context_getter_(main_context),
|
| + protocol_handler_interceptor_(protocol_handler_interceptor.Pass()) {}
|
|
|
| virtual ChromeURLRequestContext* Create() OVERRIDE {
|
| // We will copy most of the state from the main request context.
|
| + //
|
| + // Note that this factory is one-shot. After Create() is called once, the
|
| + // factory is actually destroyed. Thus it is safe to destructively pass
|
| + // state onwards.
|
| return profile_io_data_->GetIsolatedAppRequestContext(
|
| - main_request_context_getter_->GetIOContext(), app_id_);
|
| + main_request_context_getter_->GetIOContext(), app_id_,
|
| + protocol_handler_interceptor_.Pass());
|
| }
|
|
|
| private:
|
| @@ -92,6 +100,8 @@ class FactoryForIsolatedApp : public ChromeURLRequestContextFactory {
|
| const std::string app_id_;
|
| scoped_refptr<ChromeURLRequestContextGetter>
|
| main_request_context_getter_;
|
| + scoped_ptr<net::URLRequestJobFactory::Interceptor>
|
| + protocol_handler_interceptor_;
|
| };
|
|
|
| // Factory that creates the media ChromeURLRequestContext for a given isolated
|
| @@ -102,23 +112,26 @@ class FactoryForIsolatedMedia : public ChromeURLRequestContextFactory {
|
| public:
|
| FactoryForIsolatedMedia(const ProfileIOData* profile_io_data,
|
| const std::string& app_id,
|
| - ChromeURLRequestContextGetter* main_context)
|
| + ChromeURLRequestContextGetter* app_context)
|
| : profile_io_data_(profile_io_data),
|
| app_id_(app_id),
|
| - main_request_context_getter_(main_context) {}
|
| + app_context_getter_(app_context) {}
|
|
|
| virtual ChromeURLRequestContext* Create() OVERRIDE {
|
| // We will copy most of the state from the corresopnding app's
|
| - // request context, which we obtain using the main context.
|
| + // request context. We expect to have the same lifetime as
|
| + // the associated |app_context_getter_| so we can just reuse
|
| + // all its backing objects, including the
|
| + // |protocol_handler_interceptor|. This is why the API
|
| + // looks different from FactoryForIsolatedApp's.
|
| return profile_io_data_->GetIsolatedMediaRequestContext(
|
| - main_request_context_getter_->GetIOContext(), app_id_);
|
| + app_context_getter_->GetIOContext(), app_id_);
|
| }
|
|
|
| private:
|
| const ProfileIOData* const profile_io_data_;
|
| const std::string app_id_;
|
| - scoped_refptr<ChromeURLRequestContextGetter>
|
| - main_request_context_getter_;
|
| + scoped_refptr<ChromeURLRequestContextGetter> app_context_getter_;
|
| };
|
|
|
| // Factory that creates the ChromeURLRequestContext for media.
|
| @@ -214,27 +227,29 @@ ChromeURLRequestContextGetter*
|
| ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp(
|
| Profile* profile,
|
| const ProfileIOData* profile_io_data,
|
| - const std::string& app_id) {
|
| + const std::string& app_id,
|
| + scoped_ptr<net::URLRequestJobFactory::Interceptor>
|
| + protocol_handler_interceptor) {
|
| DCHECK(!profile->IsOffTheRecord());
|
| ChromeURLRequestContextGetter* main_context =
|
| static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
|
| return new ChromeURLRequestContextGetter(
|
| profile,
|
| - new FactoryForIsolatedApp(profile_io_data, app_id, main_context));
|
| + new FactoryForIsolatedApp(profile_io_data, app_id, main_context,
|
| + protocol_handler_interceptor.Pass()));
|
| }
|
|
|
| // static
|
| ChromeURLRequestContextGetter*
|
| ChromeURLRequestContextGetter::CreateOriginalForIsolatedMedia(
|
| Profile* profile,
|
| + ChromeURLRequestContextGetter* app_context,
|
| const ProfileIOData* profile_io_data,
|
| const std::string& app_id) {
|
| DCHECK(!profile->IsOffTheRecord());
|
| - ChromeURLRequestContextGetter* main_context =
|
| - static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
|
| return new ChromeURLRequestContextGetter(
|
| profile,
|
| - new FactoryForIsolatedMedia(profile_io_data, app_id, main_context));
|
| + new FactoryForIsolatedMedia(profile_io_data, app_id, app_context));
|
| }
|
|
|
| // static
|
| @@ -260,13 +275,16 @@ ChromeURLRequestContextGetter*
|
| ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(
|
| Profile* profile,
|
| const ProfileIOData* profile_io_data,
|
| - const std::string& app_id) {
|
| + const std::string& app_id,
|
| + scoped_ptr<net::URLRequestJobFactory::Interceptor>
|
| + protocol_handler_interceptor) {
|
| DCHECK(profile->IsOffTheRecord());
|
| ChromeURLRequestContextGetter* main_context =
|
| static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
|
| return new ChromeURLRequestContextGetter(
|
| profile,
|
| - new FactoryForIsolatedApp(profile_io_data, app_id, main_context));
|
| + new FactoryForIsolatedApp(profile_io_data, app_id, main_context,
|
| + protocol_handler_interceptor.Pass()));
|
| }
|
|
|
| void ChromeURLRequestContextGetter::CleanupOnUIThread() {
|
|
|