| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/client/plugin/pepper_network_manager.h" | 5 #include "remoting/client/plugin/pepper_network_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" |
| 9 #include "ppapi/cpp/module.h" | 11 #include "ppapi/cpp/module.h" |
| 10 #include "ppapi/cpp/private/network_list_private.h" | 12 #include "ppapi/cpp/private/network_list_private.h" |
| 11 #include "ppapi/cpp/private/net_address_private.h" | 13 #include "ppapi/cpp/private/net_address_private.h" |
| 12 | 14 |
| 13 namespace remoting { | 15 namespace remoting { |
| 14 | 16 |
| 15 PepperNetworkManager::PepperNetworkManager(const pp::InstanceHandle& instance) | 17 PepperNetworkManager::PepperNetworkManager(const pp::InstanceHandle& instance) |
| 16 : monitor_(instance, &PepperNetworkManager::OnNetworkListCallbackHandler, | 18 : monitor_(instance, &PepperNetworkManager::OnNetworkListCallbackHandler, |
| 17 this), | 19 this), |
| 18 start_count_(0), | 20 start_count_(0), |
| 19 network_list_received_(false), | 21 network_list_received_(false), |
| 20 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 22 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 21 } | 23 } |
| 22 | 24 |
| 23 PepperNetworkManager::~PepperNetworkManager() { | 25 PepperNetworkManager::~PepperNetworkManager() { |
| 24 DCHECK(!start_count_); | 26 DCHECK(!start_count_); |
| 25 } | 27 } |
| 26 | 28 |
| 27 void PepperNetworkManager::StartUpdating() { | 29 void PepperNetworkManager::StartUpdating() { |
| 28 if (network_list_received_) { | 30 if (network_list_received_) { |
| 29 // Post a task to avoid reentrancy. | 31 // Post a task to avoid reentrancy. |
| 30 MessageLoop::current()->PostTask( | 32 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 31 FROM_HERE, base::Bind(&PepperNetworkManager::SendNetworksChangedSignal, | 33 FROM_HERE, base::Bind(&PepperNetworkManager::SendNetworksChangedSignal, |
| 32 weak_factory_.GetWeakPtr())); | 34 weak_factory_.GetWeakPtr())); |
| 33 } | 35 } |
| 34 ++start_count_; | 36 ++start_count_; |
| 35 } | 37 } |
| 36 | 38 |
| 37 void PepperNetworkManager::StopUpdating() { | 39 void PepperNetworkManager::StopUpdating() { |
| 38 DCHECK_GT(start_count_, 0); | 40 DCHECK_GT(start_count_, 0); |
| 39 --start_count_; | 41 --start_count_; |
| 40 } | 42 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 MergeNetworkList(networks, &changed); | 104 MergeNetworkList(networks, &changed); |
| 103 if (changed) | 105 if (changed) |
| 104 SignalNetworksChanged(); | 106 SignalNetworksChanged(); |
| 105 } | 107 } |
| 106 | 108 |
| 107 void PepperNetworkManager::SendNetworksChangedSignal() { | 109 void PepperNetworkManager::SendNetworksChangedSignal() { |
| 108 SignalNetworksChanged(); | 110 SignalNetworksChanged(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 } // namespace remoting | 113 } // namespace remoting |
| OLD | NEW |