| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 if (sent_requests_.empty()) | 277 if (sent_requests_.empty()) |
| 276 return; | 278 return; |
| 277 | 279 |
| 278 // All requests should be processed FIFO, so the next item in the | 280 // All requests should be processed FIFO, so the next item in the |
| 279 // sent_requests_ queue should be the one that the plugin just created. | 281 // sent_requests_ queue should be the one that the plugin just created. |
| 280 Client* client = sent_requests_.front(); | 282 Client* client = sent_requests_.front(); |
| 281 sent_requests_.pop(); | 283 sent_requests_.pop(); |
| 282 | 284 |
| 283 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); | 285 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); |
| 284 } | 286 } |
| OLD | NEW |