Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: content/browser/ppapi_plugin_process_host.cc

Issue 9147026: API for connection type (Ethernet/WIFI/WWAN ...) in NetworkChangeNotifier. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "content/browser/plugin_service_impl.h" 12 #include "content/browser/plugin_service_impl.h"
13 #include "content/browser/renderer_host/render_message_filter.h" 13 #include "content/browser/renderer_host/render_message_filter.h"
14 #include "content/common/child_process_host_impl.h" 14 #include "content/common/child_process_host_impl.h"
15 #include "content/common/child_process_messages.h" 15 #include "content/common/child_process_messages.h"
16 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
17 #include "content/public/common/pepper_plugin_info.h" 17 #include "content/public/common/pepper_plugin_info.h"
18 #include "content/public/common/process_type.h" 18 #include "content/public/common/process_type.h"
19 #include "ipc/ipc_switches.h" 19 #include "ipc/ipc_switches.h"
20 #include "net/base/network_change_notifier.h" 20 #include "net/base/network_change_notifier.h"
21 #include "ppapi/proxy/ppapi_messages.h" 21 #include "ppapi/proxy/ppapi_messages.h"
22 22
23 using content::ChildProcessHost; 23 using content::ChildProcessHost;
24 using content::ChildProcessHostImpl; 24 using content::ChildProcessHostImpl;
25 25
26 class PpapiPluginProcessHost::PluginNetworkObserver 26 class PpapiPluginProcessHost::PluginNetworkObserver
27 : public net::NetworkChangeNotifier::IPAddressObserver, 27 : public net::NetworkChangeNotifier::IPAddressObserver,
28 public net::NetworkChangeNotifier::OnlineStateObserver { 28 public net::NetworkChangeNotifier::ConnectionStateObserver {
29 public: 29 public:
30 explicit PluginNetworkObserver(PpapiPluginProcessHost* process_host) 30 explicit PluginNetworkObserver(PpapiPluginProcessHost* process_host)
31 : process_host_(process_host) { 31 : process_host_(process_host) {
32 net::NetworkChangeNotifier::AddIPAddressObserver(this); 32 net::NetworkChangeNotifier::AddIPAddressObserver(this);
33 net::NetworkChangeNotifier::AddOnlineStateObserver(this); 33 net::NetworkChangeNotifier::AddConnectionStateObserver(this);
34 } 34 }
35 35
36 ~PluginNetworkObserver() { 36 ~PluginNetworkObserver() {
37 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this); 37 net::NetworkChangeNotifier::RemoveConnectionStateObserver(this);
38 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 38 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
39 } 39 }
40 40
41 // IPAddressObserver implementation. 41 // IPAddressObserver implementation.
42 virtual void OnIPAddressChanged() OVERRIDE { 42 virtual void OnIPAddressChanged() OVERRIDE {
43 // TODO(brettw) bug 90246: This doesn't seem correct. The online/offline 43 // TODO(brettw) bug 90246: This doesn't seem correct. The online/offline
44 // notification seems like it should be sufficient, but I don't see that 44 // notification seems like it should be sufficient, but I don't see that
45 // when I unplug and replug my network cable. Sending this notification when 45 // when I unplug and replug my network cable. Sending this notification when
46 // "something" changes seems to make Flash reasonably happy, but seems 46 // "something" changes seems to make Flash reasonably happy, but seems
47 // wrong. We should really be able to provide the real online state in 47 // wrong. We should really be able to provide the real online state in
48 // OnOnlineStateChanged(). 48 // OnOnlineStateChanged().
49 process_host_->Send(new PpapiMsg_SetNetworkState(true)); 49 process_host_->Send(new PpapiMsg_SetNetworkState(true));
50 } 50 }
51 51
52 // OnlineStateObserver implementation. 52 // OnlineStateObserver implementation.
53 virtual void OnOnlineStateChanged(bool online) OVERRIDE { 53 virtual void OnConnectionStateChanged(
54 process_host_->Send(new PpapiMsg_SetNetworkState(online)); 54 net::NetworkChangeNotifier::ConnectionState state) {
55 process_host_->Send(new PpapiMsg_SetNetworkState(
56 state != net::NetworkChangeNotifier::NONE));
55 } 57 }
56 58
57 private: 59 private:
58 PpapiPluginProcessHost* const process_host_; 60 PpapiPluginProcessHost* const process_host_;
59 }; 61 };
60 62
61 PpapiPluginProcessHost::~PpapiPluginProcessHost() { 63 PpapiPluginProcessHost::~PpapiPluginProcessHost() {
62 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") 64 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
63 << "~PpapiPluginProcessHost()"; 65 << "~PpapiPluginProcessHost()";
64 CancelRequests(); 66 CancelRequests();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, 283 ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
282 renderer_process, &renderers_plugin_handle, 284 renderer_process, &renderers_plugin_handle,
283 0, FALSE, DUPLICATE_SAME_ACCESS); 285 0, FALSE, DUPLICATE_SAME_ACCESS);
284 #elif defined(OS_POSIX) 286 #elif defined(OS_POSIX)
285 // Don't need to duplicate anything on POSIX since it's just a PID. 287 // Don't need to duplicate anything on POSIX since it's just a PID.
286 base::ProcessHandle renderers_plugin_handle = plugin_process; 288 base::ProcessHandle renderers_plugin_handle = plugin_process;
287 #endif 289 #endif
288 290
289 client->OnChannelOpened(renderers_plugin_handle, channel_handle); 291 client->OnChannelOpened(renderers_plugin_handle, channel_handle);
290 } 292 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698