| 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 "content/browser/ppapi_plugin_process_host.h" | 5 #include "content/browser/ppapi_plugin_process_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ipc/ipc_switches.h" | 22 #include "ipc/ipc_switches.h" |
| 23 #include "net/base/network_change_notifier.h" | 23 #include "net/base/network_change_notifier.h" |
| 24 #include "ppapi/proxy/ppapi_messages.h" | 24 #include "ppapi/proxy/ppapi_messages.h" |
| 25 #include "webkit/plugins/plugin_switches.h" | 25 #include "webkit/plugins/plugin_switches.h" |
| 26 | 26 |
| 27 using content::ChildProcessHost; | 27 using content::ChildProcessHost; |
| 28 using content::ChildProcessHostImpl; | 28 using content::ChildProcessHostImpl; |
| 29 | 29 |
| 30 class PpapiPluginProcessHost::PluginNetworkObserver | 30 class PpapiPluginProcessHost::PluginNetworkObserver |
| 31 : public net::NetworkChangeNotifier::IPAddressObserver, | 31 : public net::NetworkChangeNotifier::IPAddressObserver, |
| 32 public net::NetworkChangeNotifier::OnlineStateObserver { | 32 public net::NetworkChangeNotifier::ConnectionTypeObserver { |
| 33 public: | 33 public: |
| 34 explicit PluginNetworkObserver(PpapiPluginProcessHost* process_host) | 34 explicit PluginNetworkObserver(PpapiPluginProcessHost* process_host) |
| 35 : process_host_(process_host) { | 35 : process_host_(process_host) { |
| 36 net::NetworkChangeNotifier::AddIPAddressObserver(this); | 36 net::NetworkChangeNotifier::AddIPAddressObserver(this); |
| 37 net::NetworkChangeNotifier::AddOnlineStateObserver(this); | 37 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 38 } | 38 } |
| 39 | 39 |
| 40 ~PluginNetworkObserver() { | 40 ~PluginNetworkObserver() { |
| 41 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); | 41 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| 42 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 42 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // IPAddressObserver implementation. | 45 // IPAddressObserver implementation. |
| 46 virtual void OnIPAddressChanged() OVERRIDE { | 46 virtual void OnIPAddressChanged() OVERRIDE { |
| 47 // TODO(brettw) bug 90246: This doesn't seem correct. The online/offline | 47 // TODO(brettw) bug 90246: This doesn't seem correct. The online/offline |
| 48 // notification seems like it should be sufficient, but I don't see that | 48 // notification seems like it should be sufficient, but I don't see that |
| 49 // when I unplug and replug my network cable. Sending this notification when | 49 // when I unplug and replug my network cable. Sending this notification when |
| 50 // "something" changes seems to make Flash reasonably happy, but seems | 50 // "something" changes seems to make Flash reasonably happy, but seems |
| 51 // wrong. We should really be able to provide the real online state in | 51 // wrong. We should really be able to provide the real online state in |
| 52 // OnOnlineStateChanged(). | 52 // OnConnectionTypeChanged(). |
| 53 process_host_->Send(new PpapiMsg_SetNetworkState(true)); | 53 process_host_->Send(new PpapiMsg_SetNetworkState(true)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // OnlineStateObserver implementation. | 56 // ConnectionTypeObserver implementation. |
| 57 virtual void OnOnlineStateChanged(bool online) OVERRIDE { | 57 virtual void OnConnectionTypeChanged( |
| 58 process_host_->Send(new PpapiMsg_SetNetworkState(online)); | 58 net::NetworkChangeNotifier::ConnectionType type) { |
| 59 process_host_->Send(new PpapiMsg_SetNetworkState( |
| 60 type != net::NetworkChangeNotifier::CONNECTION_NONE)); |
| 59 } | 61 } |
| 60 | 62 |
| 61 private: | 63 private: |
| 62 PpapiPluginProcessHost* const process_host_; | 64 PpapiPluginProcessHost* const process_host_; |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 PpapiPluginProcessHost::~PpapiPluginProcessHost() { | 67 PpapiPluginProcessHost::~PpapiPluginProcessHost() { |
| 66 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") | 68 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") |
| 67 << "~PpapiPluginProcessHost()"; | 69 << "~PpapiPluginProcessHost()"; |
| 68 CancelRequests(); | 70 CancelRequests(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 renderer_process, &renderers_plugin_handle, | 297 renderer_process, &renderers_plugin_handle, |
| 296 0, FALSE, DUPLICATE_SAME_ACCESS); | 298 0, FALSE, DUPLICATE_SAME_ACCESS); |
| 297 #elif defined(OS_POSIX) | 299 #elif defined(OS_POSIX) |
| 298 // Don't need to duplicate anything on POSIX since it's just a PID. | 300 // Don't need to duplicate anything on POSIX since it's just a PID. |
| 299 base::ProcessHandle renderers_plugin_handle = plugin_process; | 301 base::ProcessHandle renderers_plugin_handle = plugin_process; |
| 300 #endif | 302 #endif |
| 301 | 303 |
| 302 client->OnPpapiChannelOpened(renderers_plugin_handle, channel_handle, | 304 client->OnPpapiChannelOpened(renderers_plugin_handle, channel_handle, |
| 303 process_->GetData().id); | 305 process_->GetData().id); |
| 304 } | 306 } |
| OLD | NEW |