| 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 <memory> |
| 8 |
| 7 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/linked_ptr.h" | |
| 10 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" | 12 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" |
| 12 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" | 13 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" |
| 13 #include "chrome/browser/local_discovery/endpoint_resolver.h" | 14 #include "chrome/browser/local_discovery/endpoint_resolver.h" |
| 14 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" | 15 #include "chrome/browser/local_discovery/service_discovery_shared_client.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/storage_partition.h" | 18 #include "content/public/browser/storage_partition.h" |
| 18 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| 19 | 20 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 const MessageResponseCallback& callback); | 87 const MessageResponseCallback& callback); |
| 87 | 88 |
| 88 void OnServiceResolved(int session_id, | 89 void OnServiceResolved(int session_id, |
| 89 const CreateSessionCallback& callback, | 90 const CreateSessionCallback& callback, |
| 90 const net::IPEndPoint& endpoint); | 91 const net::IPEndPoint& endpoint); |
| 91 | 92 |
| 92 scoped_refptr<local_discovery::ServiceDiscoverySharedClient> | 93 scoped_refptr<local_discovery::ServiceDiscoverySharedClient> |
| 93 service_discovery_client_; | 94 service_discovery_client_; |
| 94 | 95 |
| 95 struct SessionInfo { | 96 struct SessionInfo { |
| 96 linked_ptr<PrivetV3Session> session; | 97 std::unique_ptr<PrivetV3Session> session; |
| 97 linked_ptr<local_discovery::EndpointResolver> resolver; | 98 std::unique_ptr<local_discovery::EndpointResolver> resolver; |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 std::map<int, SessionInfo> sessions_; | 101 std::map<int, SessionInfo> sessions_; |
| 101 int last_session_id_ = 0; | 102 int last_session_id_ = 0; |
| 102 | 103 |
| 103 content::BrowserContext* const browser_context_; | 104 content::BrowserContext* const browser_context_; |
| 104 | 105 |
| 105 scoped_refptr<PrivetV3ContextGetter> context_getter_; | 106 scoped_refptr<PrivetV3ContextGetter> context_getter_; |
| 106 | 107 |
| 107 base::WeakPtrFactory<GcdPrivateAPIImpl> weak_ptr_factory_{this}; | 108 base::WeakPtrFactory<GcdPrivateAPIImpl> weak_ptr_factory_{this}; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 438 |
| 438 GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile()); | 439 GcdPrivateAPIImpl* gcd_api = GcdPrivateAPIImpl::Get(GetProfile()); |
| 439 | 440 |
| 440 gcd_api->RemoveSession(params->session_id); | 441 gcd_api->RemoveSession(params->session_id); |
| 441 | 442 |
| 442 SendResponse(true); | 443 SendResponse(true); |
| 443 return true; | 444 return true; |
| 444 } | 445 } |
| 445 | 446 |
| 446 } // namespace extensions | 447 } // namespace extensions |
| OLD | NEW |