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

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

Issue 2891773002: Add a stub implementation of the URLLoaderFactory for AppCache. (Closed)
Patch Set: Fix compile failures Created 3 years, 7 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"
8 9
9 namespace content { 10 namespace content {
10 11
11 URLLoaderFactoryGetter::URLLoaderFactoryGetter() {} 12 URLLoaderFactoryGetter::URLLoaderFactoryGetter() {}
12 13
13 void URLLoaderFactoryGetter::Initialize( 14 void URLLoaderFactoryGetter::Initialize(
14 mojom::URLLoaderFactoryPtr network_factory) { 15 mojom::URLLoaderFactoryPtr network_factory,
16 ChromeAppCacheService* appcache_service) {
15 BrowserThread::PostTask( 17 BrowserThread::PostTask(
16 BrowserThread::IO, FROM_HERE, 18 BrowserThread::IO, FROM_HERE,
17 base::BindOnce(&URLLoaderFactoryGetter::InitializeOnIOThread, this, 19 base::BindOnce(&URLLoaderFactoryGetter::InitializeOnIOThread, this,
18 network_factory.PassInterface())); 20 network_factory.PassInterface(), appcache_service));
19 } 21 }
20 22
21 mojom::URLLoaderFactoryPtr* URLLoaderFactoryGetter::GetNetworkFactory() { 23 mojom::URLLoaderFactoryPtr* URLLoaderFactoryGetter::GetNetworkFactory() {
22 DCHECK_CURRENTLY_ON(BrowserThread::IO); 24 DCHECK_CURRENTLY_ON(BrowserThread::IO);
23 return test_factory_.is_bound() ? &test_factory_ : &network_factory_; 25 return test_factory_.is_bound() ? &test_factory_ : &network_factory_;
24 } 26 }
25 27
26 void URLLoaderFactoryGetter::SetNetworkFactoryForTesting( 28 void URLLoaderFactoryGetter::SetNetworkFactoryForTesting(
27 mojom::URLLoaderFactoryPtr test_factory) { 29 mojom::URLLoaderFactoryPtr test_factory) {
28 // Since the URLLoaderFactory pointers are bound on the IO thread, and this 30 // Since the URLLoaderFactory pointers are bound on the IO thread, and this
29 // method is called on the UI thread, we are not able to unbind and return the 31 // method is called on the UI thread, we are not able to unbind and return the
30 // old value. As such this class keeps two separate pointers, one for test. 32 // old value. As such this class keeps two separate pointers, one for test.
31 BrowserThread::PostTask( 33 BrowserThread::PostTask(
32 BrowserThread::IO, FROM_HERE, 34 BrowserThread::IO, FROM_HERE,
33 base::BindOnce(&URLLoaderFactoryGetter::SetTestNetworkFactoryOnIOThread, 35 base::BindOnce(&URLLoaderFactoryGetter::SetTestNetworkFactoryOnIOThread,
34 this, test_factory.PassInterface())); 36 this, test_factory.PassInterface()));
35 } 37 }
36 38
39 mojom::URLLoaderFactoryPtr* URLLoaderFactoryGetter::GetAppCacheFactory() {
40 DCHECK_CURRENTLY_ON(BrowserThread::IO);
41 return &appcache_factory_;
42 }
43
37 URLLoaderFactoryGetter::~URLLoaderFactoryGetter() {} 44 URLLoaderFactoryGetter::~URLLoaderFactoryGetter() {}
38 45
39 void URLLoaderFactoryGetter::InitializeOnIOThread( 46 void URLLoaderFactoryGetter::InitializeOnIOThread(
40 mojom::URLLoaderFactoryPtrInfo network_factory) { 47 mojom::URLLoaderFactoryPtrInfo network_factory,
48 ChromeAppCacheService* appcache_service) {
41 network_factory_.Bind(std::move(network_factory)); 49 network_factory_.Bind(std::move(network_factory));
50
51 AppCacheURLLoaderFactory::CreateURLLoaderFactory(
52 mojo::MakeRequest(&appcache_factory_), appcache_service, this);
42 } 53 }
43 54
44 void URLLoaderFactoryGetter::SetTestNetworkFactoryOnIOThread( 55 void URLLoaderFactoryGetter::SetTestNetworkFactoryOnIOThread(
45 mojom::URLLoaderFactoryPtrInfo test_factory) { 56 mojom::URLLoaderFactoryPtrInfo test_factory) {
46 test_factory_.Bind(std::move(test_factory)); 57 test_factory_.Bind(std::move(test_factory));
47 } 58 }
48 59
49 } // namespace content 60 } // namespace content
OLDNEW
« content/browser/storage_partition_impl.cc ('K') | « content/browser/url_loader_factory_getter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698