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