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

Side by Side Diff: ppapi/proxy/network_monitor_resource.cc

Issue 23819033: Simplify PPB_NetworkMonitor proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation after r169825 Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/network_monitor_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/proxy/network_monitor_resource.h"
6
7 #include "ppapi/proxy/dispatch_reply_message.h"
8 #include "ppapi/proxy/ppapi_messages.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_network_monitor_api.h"
11
12 namespace ppapi {
13 namespace proxy {
14
15 NetworkMonitorResource::NetworkMonitorResource(Connection connection,
16 PP_Instance instance)
17 : PluginResource(connection, instance),
18 current_list_(0),
19 forbidden_(false),
20 network_list_(NULL) {
21 SendCreate(BROWSER, PpapiHostMsg_NetworkMonitor_Create());
22 }
23
24 NetworkMonitorResource::~NetworkMonitorResource() {}
25
26 ppapi::thunk::PPB_NetworkMonitor_API*
27 NetworkMonitorResource::AsPPB_NetworkMonitor_API() {
28 return this;
29 }
30
31 void NetworkMonitorResource::OnReplyReceived(
32 const ResourceMessageReplyParams& params,
33 const IPC::Message& msg) {
34 IPC_BEGIN_MESSAGE_MAP(NetworkMonitorResource, msg)
35 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
36 PpapiPluginMsg_NetworkMonitor_NetworkList, OnPluginMsgNetworkList)
37 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_0(
38 PpapiPluginMsg_NetworkMonitor_Forbidden, OnPluginMsgForbidden)
39 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
40 PluginResource::OnReplyReceived(params, msg))
41 IPC_END_MESSAGE_MAP()
42 }
43
44 int32_t NetworkMonitorResource::UpdateNetworkList(
45 PP_Resource* network_list,
46 scoped_refptr<TrackedCallback> callback) {
47 if (!network_list)
48 return PP_ERROR_BADARGUMENT;
49 if (TrackedCallback::IsPending(update_callback_))
50 return PP_ERROR_INPROGRESS;
51 if (forbidden_)
52 return PP_ERROR_NOACCESS;
53
54 if (current_list_.get()) {
55 *network_list = current_list_.Release();
56 return PP_OK;
57 }
58
59 network_list_ = network_list;
60 update_callback_ = callback;
61 return PP_OK_COMPLETIONPENDING;
62 }
63
64 void NetworkMonitorResource::OnPluginMsgNetworkList(
65 const ResourceMessageReplyParams& params,
66 const SerializedNetworkList& list) {
67 current_list_ = ScopedPPResource(
68 new NetworkListResource(pp_instance(), list));
69
70 if (TrackedCallback::IsPending(update_callback_)) {
71 *network_list_ = current_list_.Release();
72 update_callback_->Run(PP_OK);
73 }
74 }
75
76 void NetworkMonitorResource::OnPluginMsgForbidden(
77 const ResourceMessageReplyParams& params) {
78 forbidden_ = true;
79
80 if (TrackedCallback::IsPending(update_callback_))
81 update_callback_->Run(PP_ERROR_NOACCESS);
82 }
83
84 } // namespace proxy
85 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/network_monitor_resource.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698