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

Side by Side Diff: chrome/browser/net/profile_network_context_service.cc

Issue 2976323002: Hook up ProfileIOData's URLRequestContext to a NetworkService. (Closed)
Patch Set: Response to comments Created 3 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/net/profile_network_context_service.h"
6
7 #include "base/feature_list.h"
8 #include "base/logging.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/network_service_instance.h"
13 #include "content/public/browser/storage_partition.h"
14 #include "content/public/common/content_features.h"
15 #include "content/public/common/service_names.mojom.h"
16 #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
17
18 namespace {
19
20 content::mojom::NetworkContextParamsPtr CreateMainNetworkContextParams() {
21 // TODO(mmenke): Set up parameters here.
22 return content::mojom::NetworkContextParams::New();
23 }
24
25 } // namespace
26
27 ProfileNetworkContextService::ProfileNetworkContextService(Profile* profile)
28 : profile_(profile) {}
29
30 ProfileNetworkContextService::~ProfileNetworkContextService() {}
31
32 void ProfileNetworkContextService::SetUpProfileIODataMainContext(
33 content::mojom::NetworkContextRequest* network_context_request,
34 content::mojom::NetworkContextParamsPtr* network_context_params) {
35 DCHECK(!profile_io_data_main_network_context_);
36 *network_context_request =
37 mojo::MakeRequest(&profile_io_data_main_network_context_);
38 if (!base::FeatureList::IsEnabled(features::kNetworkService)) {
39 *network_context_params = CreateMainNetworkContextParams();
40 } else {
41 // Just use default if network service is enabled, to avoid the legacy
42 // in-process URLRequestContext from fighting with the NetworkService over
43 // ownership of on-disk files.
44 *network_context_params = content::mojom::NetworkContextParams::New();
45 }
46 }
47
48 content::mojom::NetworkContext* ProfileNetworkContextService::MainContext() {
49 // ProfileIOData must be initialized before this call.
50 DCHECK(profile_io_data_main_network_context_);
51 if (!base::FeatureList::IsEnabled(features::kNetworkService))
52 return profile_io_data_main_network_context_.get();
53
54 return content::BrowserContext::GetDefaultStoragePartition(profile_)
55 ->GetNetworkContext();
56 }
57
58 content::mojom::NetworkContextPtr
59 ProfileNetworkContextService::CreateMainNetworkContext() {
60 DCHECK(base::FeatureList::IsEnabled(features::kNetworkService));
61
62 content::mojom::NetworkContextPtr network_context;
63 content::GetNetworkService()->CreateNetworkContext(
64 MakeRequest(&network_context), CreateMainNetworkContextParams());
65 return network_context;
66 }
OLDNEW
« no previous file with comments | « chrome/browser/net/profile_network_context_service.h ('k') | chrome/browser/net/profile_network_context_service_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698