OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/extensions/api/gcd_private/gcd_private_api.h" | 5 #include "chrome/browser/extensions/api/gcd_private/gcd_private_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
11 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" | 11 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" |
12 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" | 12 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" |
13 #include "chrome/browser/local_discovery/endpoint_resolver.h" | 13 #include "chrome/browser/local_discovery/endpoint_resolver.h" |
14 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 14 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/storage_partition.h" |
17 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
18 | 19 |
19 namespace extensions { | 20 namespace extensions { |
20 | 21 |
21 namespace gcd_private = api::gcd_private; | 22 namespace gcd_private = api::gcd_private; |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 const char kPrivatAPISetup[] = "/privet/v3/setup/start"; | 26 const char kPrivatAPISetup[] = "/privet/v3/setup/start"; |
26 const char kPrivetKeyWifi[] = "wifi"; | 27 const char kPrivetKeyWifi[] = "wifi"; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 const CreateSessionCallback& callback, | 138 const CreateSessionCallback& callback, |
138 const net::IPEndPoint& endpoint) { | 139 const net::IPEndPoint& endpoint) { |
139 if (endpoint.address().empty()) { | 140 if (endpoint.address().empty()) { |
140 return callback.Run(session_id, gcd_private::STATUS_SERVICERESOLUTIONERROR, | 141 return callback.Run(session_id, gcd_private::STATUS_SERVICERESOLUTIONERROR, |
141 base::DictionaryValue()); | 142 base::DictionaryValue()); |
142 } | 143 } |
143 auto& session_data = sessions_[session_id]; | 144 auto& session_data = sessions_[session_id]; |
144 | 145 |
145 if (!context_getter_) { | 146 if (!context_getter_) { |
146 context_getter_ = new PrivetV3ContextGetter( | 147 context_getter_ = new PrivetV3ContextGetter( |
147 browser_context_->GetRequestContext()->GetNetworkTaskRunner()); | 148 content::BrowserContext::GetDefaultStoragePartition(browser_context_)-> |
| 149 GetURLRequestContext()->GetNetworkTaskRunner()); |
148 } | 150 } |
149 | 151 |
150 session_data.session.reset(new PrivetV3Session( | 152 session_data.session.reset(new PrivetV3Session( |
151 context_getter_, net::HostPortPair::FromIPEndPoint(endpoint))); | 153 context_getter_, net::HostPortPair::FromIPEndPoint(endpoint))); |
152 session_data.session->Init(base::Bind(callback, session_id)); | 154 session_data.session->Init(base::Bind(callback, session_id)); |
153 } | 155 } |
154 | 156 |
155 void GcdPrivateAPIImpl::StartPairing(int session_id, | 157 void GcdPrivateAPIImpl::StartPairing(int session_id, |
156 api::gcd_private::PairingType pairing_type, | 158 api::gcd_private::PairingType pairing_type, |
157 const SessionCallback& callback) { | 159 const SessionCallback& callback) { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 | 437 |
436 GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile()); | 438 GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile()); |
437 | 439 |
438 gcd_api->RemoveSession(params->session_id); | 440 gcd_api->RemoveSession(params->session_id); |
439 | 441 |
440 SendResponse(true); | 442 SendResponse(true); |
441 return true; | 443 return true; |
442 } | 444 } |
443 | 445 |
444 } // namespace extensions | 446 } // namespace extensions |
OLD | NEW |