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

Side by Side Diff: ppapi/cpp/websocket.cc

Issue 9381010: Convert resources to take an instance key instead of an Instance*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: USELESS PATCH TITLE Created 8 years, 10 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/cpp/websocket.h ('k') | ppapi/example/example.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ppapi/cpp/websocket.h" 5 #include "ppapi/cpp/websocket.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/pp_macros.h" 8 #include "ppapi/c/pp_macros.h"
9 #include "ppapi/cpp/completion_callback.h" 9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/instance.h" 10 #include "ppapi/cpp/instance_handle.h"
11 #include "ppapi/cpp/module.h" 11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/module_impl.h" 12 #include "ppapi/cpp/module_impl.h"
13 #include "ppapi/cpp/var.h" 13 #include "ppapi/cpp/var.h"
14 14
15 namespace pp { 15 namespace pp {
16 16
17 namespace { 17 namespace {
18 18
19 template <> const char* interface_name<PPB_WebSocket>() { 19 template <> const char* interface_name<PPB_WebSocket>() {
20 return PPB_WEBSOCKET_INTERFACE; 20 return PPB_WEBSOCKET_INTERFACE;
21 } 21 }
22 22
23 } // namespace 23 } // namespace
24 24
25 WebSocket::WebSocket(Instance* instance) { 25 WebSocket::WebSocket(const InstanceHandle& instance) {
26 if (!has_interface<PPB_WebSocket>()) 26 if (!has_interface<PPB_WebSocket>())
27 return; 27 return;
28 PassRefFromConstructor(get_interface<PPB_WebSocket>()->Create( 28 PassRefFromConstructor(get_interface<PPB_WebSocket>()->Create(
29 instance->pp_instance())); 29 instance.pp_instance()));
30 } 30 }
31 31
32 WebSocket::~WebSocket() { 32 WebSocket::~WebSocket() {
33 } 33 }
34 34
35 int32_t WebSocket::Connect(const Var& url, const Var protocols[], 35 int32_t WebSocket::Connect(const Var& url, const Var protocols[],
36 uint32_t protocol_count, const CompletionCallback& callback) { 36 uint32_t protocol_count, const CompletionCallback& callback) {
37 if (!has_interface<PPB_WebSocket>()) 37 if (!has_interface<PPB_WebSocket>())
38 return PP_ERROR_BADRESOURCE; 38 return PP_ERROR_BADRESOURCE;
39 39
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (!has_interface<PPB_WebSocket>()) 94 if (!has_interface<PPB_WebSocket>())
95 return 0; 95 return 0;
96 96
97 return get_interface<PPB_WebSocket>()->GetCloseCode(pp_resource()); 97 return get_interface<PPB_WebSocket>()->GetCloseCode(pp_resource());
98 } 98 }
99 99
100 Var WebSocket::GetCloseReason() { 100 Var WebSocket::GetCloseReason() {
101 if (!has_interface<PPB_WebSocket>()) 101 if (!has_interface<PPB_WebSocket>())
102 return 0; 102 return 0;
103 103
104 return Var(Var::PassRef(), 104 return Var(PASS_REF,
105 get_interface<PPB_WebSocket>()->GetCloseReason(pp_resource())); 105 get_interface<PPB_WebSocket>()->GetCloseReason(pp_resource()));
106 } 106 }
107 107
108 bool WebSocket::GetCloseWasClean() { 108 bool WebSocket::GetCloseWasClean() {
109 if (!has_interface<PPB_WebSocket>()) 109 if (!has_interface<PPB_WebSocket>())
110 return false; 110 return false;
111 111
112 PP_Bool result = 112 PP_Bool result =
113 get_interface<PPB_WebSocket>()->GetCloseWasClean(pp_resource()); 113 get_interface<PPB_WebSocket>()->GetCloseWasClean(pp_resource());
114 return PP_ToBool(result); 114 return PP_ToBool(result);
115 } 115 }
116 116
117 Var WebSocket::GetExtensions() { 117 Var WebSocket::GetExtensions() {
118 if (!has_interface<PPB_WebSocket>()) 118 if (!has_interface<PPB_WebSocket>())
119 return Var(); 119 return Var();
120 120
121 return Var(Var::PassRef(), 121 return Var(PASS_REF,
122 get_interface<PPB_WebSocket>()->GetExtensions(pp_resource())); 122 get_interface<PPB_WebSocket>()->GetExtensions(pp_resource()));
123 } 123 }
124 124
125 Var WebSocket::GetProtocol() { 125 Var WebSocket::GetProtocol() {
126 if (!has_interface<PPB_WebSocket>()) 126 if (!has_interface<PPB_WebSocket>())
127 return Var(); 127 return Var();
128 128
129 return Var(Var::PassRef(), 129 return Var(PASS_REF,
130 get_interface<PPB_WebSocket>()->GetProtocol(pp_resource())); 130 get_interface<PPB_WebSocket>()->GetProtocol(pp_resource()));
131 } 131 }
132 132
133 PP_WebSocketReadyState WebSocket::GetReadyState() { 133 PP_WebSocketReadyState WebSocket::GetReadyState() {
134 if (!has_interface<PPB_WebSocket>()) 134 if (!has_interface<PPB_WebSocket>())
135 return PP_WEBSOCKETREADYSTATE_INVALID; 135 return PP_WEBSOCKETREADYSTATE_INVALID;
136 136
137 return get_interface<PPB_WebSocket>()->GetReadyState(pp_resource()); 137 return get_interface<PPB_WebSocket>()->GetReadyState(pp_resource());
138 } 138 }
139 139
140 Var WebSocket::GetURL() { 140 Var WebSocket::GetURL() {
141 if (!has_interface<PPB_WebSocket>()) 141 if (!has_interface<PPB_WebSocket>())
142 return Var(); 142 return Var();
143 143
144 return Var(Var::PassRef(), 144 return Var(PASS_REF,
145 get_interface<PPB_WebSocket>()->GetURL(pp_resource())); 145 get_interface<PPB_WebSocket>()->GetURL(pp_resource()));
146 } 146 }
147 147
148 } // namespace pp 148 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/websocket.h ('k') | ppapi/example/example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698