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

Side by Side Diff: mojo/services/network/network_service_delegate.cc

Issue 1743473002: Change Mojo URLs to structured names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@18collapse
Patch Set: . Created 4 years, 9 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
« no previous file with comments | « mojo/public/tools/manifest/manifest_collator.py ('k') | mojo/services/package_manager/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/services/network/network_service_delegate.h" 5 #include "mojo/services/network/network_service_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 30 matching lines...) Expand all
41 NetworkServiceDelegateObserver* observer) { 41 NetworkServiceDelegateObserver* observer) {
42 observers_.AddObserver(observer); 42 observers_.AddObserver(observer);
43 } 43 }
44 44
45 void NetworkServiceDelegate::RemoveObserver( 45 void NetworkServiceDelegate::RemoveObserver(
46 NetworkServiceDelegateObserver* observer) { 46 NetworkServiceDelegateObserver* observer) {
47 observers_.RemoveObserver(observer); 47 observers_.RemoveObserver(observer);
48 } 48 }
49 49
50 void NetworkServiceDelegate::Initialize(Connector* connector, 50 void NetworkServiceDelegate::Initialize(Connector* connector,
51 const std::string& url, 51 const std::string& name,
52 uint32_t id, uint32_t user_id) { 52 uint32_t id, uint32_t user_id) {
53 // TODO(erg): Find everything else that writes to the filesystem and 53 // TODO(erg): Find everything else that writes to the filesystem and
54 // transition it to proxying mojo:filesystem. We shouldn't have any path 54 // transition it to proxying mojo:filesystem. We shouldn't have any path
55 // calculation code here, but sadly need it until the transition is done. In 55 // calculation code here, but sadly need it until the transition is done. In
56 // the mean time, manually handle the user-data-dir switch (which gets set in 56 // the mean time, manually handle the user-data-dir switch (which gets set in
57 // tests) so that tests are writing to a temp dir. 57 // tests) so that tests are writing to a temp dir.
58 base::FilePath base_path; 58 base::FilePath base_path;
59 const base::CommandLine* command_line = 59 const base::CommandLine* command_line =
60 base::CommandLine::ForCurrentProcess(); 60 base::CommandLine::ForCurrentProcess();
61 if (command_line->HasSwitch(kUserDataDir)) { 61 if (command_line->HasSwitch(kUserDataDir)) {
62 base_path = command_line->GetSwitchValuePath(kUserDataDir); 62 base_path = command_line->GetSwitchValuePath(kUserDataDir);
63 } else { 63 } else {
64 CHECK(PathService::Get(base::DIR_TEMP, &base_path)); 64 CHECK(PathService::Get(base::DIR_TEMP, &base_path));
65 base_path = base_path.Append(FILE_PATH_LITERAL("network_service")); 65 base_path = base_path.Append(FILE_PATH_LITERAL("network_service"));
66 } 66 }
67 67
68 context_.reset(new NetworkContext(base_path, this)); 68 context_.reset(new NetworkContext(base_path, this));
69 tracing_.Initialize(connector, url); 69 tracing_.Initialize(connector, name);
70 } 70 }
71 71
72 bool NetworkServiceDelegate::AcceptConnection(Connection* connection) { 72 bool NetworkServiceDelegate::AcceptConnection(Connection* connection) {
73 DCHECK(context_); 73 DCHECK(context_);
74 connection->AddInterface<CookieStore>(this); 74 connection->AddInterface<CookieStore>(this);
75 connection->AddInterface<NetworkService>(this); 75 connection->AddInterface<NetworkService>(this);
76 connection->AddInterface<URLLoaderFactory>(this); 76 connection->AddInterface<URLLoaderFactory>(this);
77 connection->AddInterface<WebSocketFactory>(this); 77 connection->AddInterface<WebSocketFactory>(this);
78 return true; 78 return true;
79 } 79 }
80 80
81 bool NetworkServiceDelegate::ShellConnectionLost() { 81 bool NetworkServiceDelegate::ShellConnectionLost() {
82 return true; 82 return true;
83 } 83 }
84 84
85 void NetworkServiceDelegate::Create(Connection* connection, 85 void NetworkServiceDelegate::Create(Connection* connection,
86 InterfaceRequest<NetworkService> request) { 86 InterfaceRequest<NetworkService> request) {
87 new NetworkServiceImpl(ref_factory_.CreateRef(), std::move(request)); 87 new NetworkServiceImpl(ref_factory_.CreateRef(), std::move(request));
88 } 88 }
89 89
90 void NetworkServiceDelegate::Create(Connection* connection, 90 void NetworkServiceDelegate::Create(Connection* connection,
91 InterfaceRequest<CookieStore> request) { 91 InterfaceRequest<CookieStore> request) {
92 // TODO(beng): need to find a way to get content origin.
92 new CookieStoreImpl( 93 new CookieStoreImpl(
93 context_.get(), GURL(connection->GetRemoteApplicationURL()).GetOrigin(), 94 context_.get(), GURL(),
94 ref_factory_.CreateRef(), std::move(request)); 95 ref_factory_.CreateRef(), std::move(request));
95 } 96 }
96 97
97 void NetworkServiceDelegate::Create( 98 void NetworkServiceDelegate::Create(
98 Connection* connection, 99 Connection* connection,
99 InterfaceRequest<WebSocketFactory> request) { 100 InterfaceRequest<WebSocketFactory> request) {
100 new WebSocketFactoryImpl(context_.get(), ref_factory_.CreateRef(), 101 new WebSocketFactoryImpl(context_.get(), ref_factory_.CreateRef(),
101 std::move(request)); 102 std::move(request));
102 } 103 }
103 104
104 void NetworkServiceDelegate::Create( 105 void NetworkServiceDelegate::Create(
105 Connection* connection, 106 Connection* connection,
106 InterfaceRequest<URLLoaderFactory> request) { 107 InterfaceRequest<URLLoaderFactory> request) {
107 new URLLoaderFactoryImpl(context_.get(), ref_factory_.CreateRef(), 108 new URLLoaderFactoryImpl(context_.get(), ref_factory_.CreateRef(),
108 std::move(request)); 109 std::move(request));
109 } 110 }
110 111
111 void NetworkServiceDelegate::Quit() { 112 void NetworkServiceDelegate::Quit() {
112 // Destroy the NetworkContext now as it requires MessageLoop::current() upon 113 // Destroy the NetworkContext now as it requires MessageLoop::current() upon
113 // destruction and it is the last moment we know for sure that it is 114 // destruction and it is the last moment we know for sure that it is
114 // running. 115 // running.
115 context_.reset(); 116 context_.reset();
116 } 117 }
117 118
118 } // namespace mojo 119 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/tools/manifest/manifest_collator.py ('k') | mojo/services/package_manager/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698