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

Side by Side Diff: content/browser/url_loader_factory_getter.cc

Issue 2902653002: Get main frame and subframe AppCache loads to work. (Closed)
Patch Set: Fix compile failures Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "content/browser/url_loader_factory_getter.h" 5 #include "content/browser/url_loader_factory_getter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/appcache/appcache_url_loader_factory.h"
9 #include "content/browser/storage_partition_impl.h" 8 #include "content/browser/storage_partition_impl.h"
10 #include "content/common/network_service.mojom.h" 9 #include "content/common/network_service.mojom.h"
11 10
12 namespace content { 11 namespace content {
13 12
14 URLLoaderFactoryGetter::URLLoaderFactoryGetter() {} 13 URLLoaderFactoryGetter::URLLoaderFactoryGetter() {}
15 14
16 void URLLoaderFactoryGetter::Initialize(StoragePartitionImpl* partition) { 15 void URLLoaderFactoryGetter::Initialize(StoragePartitionImpl* partition) {
17 mojom::URLLoaderFactoryPtr network_factory; 16 mojom::URLLoaderFactoryPtr network_factory;
18 partition->network_context()->CreateURLLoaderFactory( 17 partition->network_context()->CreateURLLoaderFactory(
19 MakeRequest(&network_factory), 0); 18 MakeRequest(&network_factory), 0);
20 19
21 BrowserThread::PostTask( 20 BrowserThread::PostTask(
22 BrowserThread::IO, FROM_HERE, 21 BrowserThread::IO, FROM_HERE,
23 base::BindOnce(&URLLoaderFactoryGetter::InitializeOnIOThread, this, 22 base::BindOnce(&URLLoaderFactoryGetter::InitializeOnIOThread, this,
24 network_factory.PassInterface(), 23 network_factory.PassInterface()));
25 scoped_refptr<ChromeAppCacheService>(
26 partition->GetAppCacheService())));
27 } 24 }
28 25
29 mojom::URLLoaderFactoryPtr* URLLoaderFactoryGetter::GetNetworkFactory() { 26 mojom::URLLoaderFactoryPtr* URLLoaderFactoryGetter::GetNetworkFactory() {
30 DCHECK_CURRENTLY_ON(BrowserThread::IO); 27 DCHECK_CURRENTLY_ON(BrowserThread::IO);
31 return test_factory_.is_bound() ? &test_factory_ : &network_factory_; 28 return test_factory_.is_bound() ? &test_factory_ : &network_factory_;
32 } 29 }
33 30
34 void URLLoaderFactoryGetter::SetNetworkFactoryForTesting( 31 void URLLoaderFactoryGetter::SetNetworkFactoryForTesting(
35 mojom::URLLoaderFactoryPtr test_factory) { 32 mojom::URLLoaderFactoryPtr test_factory) {
36 // Since the URLLoaderFactory pointers are bound on the IO thread, and this 33 // Since the URLLoaderFactory pointers are bound on the IO thread, and this
37 // method is called on the UI thread, we are not able to unbind and return the 34 // method is called on the UI thread, we are not able to unbind and return the
38 // old value. As such this class keeps two separate pointers, one for test. 35 // old value. As such this class keeps two separate pointers, one for test.
39 BrowserThread::PostTask( 36 BrowserThread::PostTask(
40 BrowserThread::IO, FROM_HERE, 37 BrowserThread::IO, FROM_HERE,
41 base::BindOnce(&URLLoaderFactoryGetter::SetTestNetworkFactoryOnIOThread, 38 base::BindOnce(&URLLoaderFactoryGetter::SetTestNetworkFactoryOnIOThread,
42 this, test_factory.PassInterface())); 39 this, test_factory.PassInterface()));
43 } 40 }
44 41
45 mojom::URLLoaderFactoryPtr* URLLoaderFactoryGetter::GetAppCacheFactory() {
46 DCHECK_CURRENTLY_ON(BrowserThread::IO);
47 return &appcache_factory_;
48 }
49
50 URLLoaderFactoryGetter::~URLLoaderFactoryGetter() {} 42 URLLoaderFactoryGetter::~URLLoaderFactoryGetter() {}
51 43
52 void URLLoaderFactoryGetter::InitializeOnIOThread( 44 void URLLoaderFactoryGetter::InitializeOnIOThread(
53 mojom::URLLoaderFactoryPtrInfo network_factory, 45 mojom::URLLoaderFactoryPtrInfo network_factory) {
54 scoped_refptr<ChromeAppCacheService> appcache_service) {
55 network_factory_.Bind(std::move(network_factory)); 46 network_factory_.Bind(std::move(network_factory));
56
57 AppCacheURLLoaderFactory::CreateURLLoaderFactory(
58 mojo::MakeRequest(&appcache_factory_), appcache_service.get(), this);
59 } 47 }
60 48
61 void URLLoaderFactoryGetter::SetTestNetworkFactoryOnIOThread( 49 void URLLoaderFactoryGetter::SetTestNetworkFactoryOnIOThread(
62 mojom::URLLoaderFactoryPtrInfo test_factory) { 50 mojom::URLLoaderFactoryPtrInfo test_factory) {
63 test_factory_.Bind(std::move(test_factory)); 51 test_factory_.Bind(std::move(test_factory));
64 } 52 }
65 53
66 } // namespace content 54 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698