OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 virtual bool Prepare() OVERRIDE; | 130 virtual bool Prepare() OVERRIDE; |
131 virtual void AsyncWorkStart() OVERRIDE; | 131 virtual void AsyncWorkStart() OVERRIDE; |
132 | 132 |
133 private: | 133 private: |
134 DECLARE_EXTENSION_FUNCTION("cast.channel.open", CAST_CHANNEL_OPEN) | 134 DECLARE_EXTENSION_FUNCTION("cast.channel.open", CAST_CHANNEL_OPEN) |
135 | 135 |
136 // Parses the cast:// or casts:// |url|, fills |connect_info| with the | 136 // Parses the cast:// or casts:// |url|, fills |connect_info| with the |
137 // corresponding details, and returns true. Returns false if |url| is not a | 137 // corresponding details, and returns true. Returns false if |url| is not a |
138 // valid Cast URL. | 138 // valid Cast URL. |
139 static bool ParseChannelUrl(const GURL& url, | 139 static bool ParseChannelUrl(const GURL& url, |
140 cast_channel::ConnectInfo* connect_info); | 140 api::cast_channel::ConnectInfo* connect_info); |
141 | 141 |
142 // Validates that |connect_info| represents a valid IP end point and returns a | 142 // Validates that |connect_info| represents a valid IP end point and returns a |
143 // new IPEndPoint if so. Otherwise returns NULL. | 143 // new IPEndPoint if so. Otherwise returns NULL. |
144 static net::IPEndPoint* ParseConnectInfo( | 144 static net::IPEndPoint* ParseConnectInfo( |
145 const cast_channel::ConnectInfo& connect_info); | 145 const api::cast_channel::ConnectInfo& connect_info); |
146 | 146 |
147 void OnOpen(int result); | 147 void OnOpen(int result); |
148 | 148 |
149 scoped_ptr<cast_channel::Open::Params> params_; | 149 scoped_ptr<cast_channel::Open::Params> params_; |
150 // The id of the newly opened socket. | 150 // The id of the newly opened socket. |
151 int new_channel_id_; | 151 int new_channel_id_; |
152 CastChannelAPI* api_; | 152 CastChannelAPI* api_; |
153 scoped_ptr<cast_channel::ConnectInfo> connect_info_; | 153 scoped_ptr<api::cast_channel::ConnectInfo> connect_info_; |
154 scoped_ptr<net::IPEndPoint> ip_endpoint_; | 154 scoped_ptr<net::IPEndPoint> ip_endpoint_; |
155 cast_channel::ChannelAuthType channel_auth_; | 155 api::cast_channel::ChannelAuthType channel_auth_; |
156 | 156 |
157 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseChannelUrl); | 157 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseChannelUrl); |
158 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseConnectInfo); | 158 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseConnectInfo); |
159 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestPrepareValidUrl); | |
160 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestPrepareInvalidUrl); | |
161 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, | |
162 TestPrepareValidConnectInfo); | |
163 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, | |
164 TestPrepareInvalidConnectInfo); | |
165 DISALLOW_COPY_AND_ASSIGN(CastChannelOpenFunction); | 159 DISALLOW_COPY_AND_ASSIGN(CastChannelOpenFunction); |
166 }; | 160 }; |
167 | 161 |
168 class CastChannelSendFunction : public CastChannelAsyncApiFunction { | 162 class CastChannelSendFunction : public CastChannelAsyncApiFunction { |
169 public: | 163 public: |
170 CastChannelSendFunction(); | 164 CastChannelSendFunction(); |
171 | 165 |
172 protected: | 166 protected: |
173 virtual ~CastChannelSendFunction(); | 167 virtual ~CastChannelSendFunction(); |
174 | 168 |
175 // AsyncApiFunction: | 169 // AsyncApiFunction: |
176 virtual bool Prepare() OVERRIDE; | 170 virtual bool Prepare() OVERRIDE; |
177 virtual void AsyncWorkStart() OVERRIDE; | 171 virtual void AsyncWorkStart() OVERRIDE; |
178 | 172 |
179 private: | 173 private: |
180 DECLARE_EXTENSION_FUNCTION("cast.channel.send", CAST_CHANNEL_SEND) | 174 DECLARE_EXTENSION_FUNCTION("cast.channel.send", CAST_CHANNEL_SEND) |
181 | 175 |
182 void OnSend(int result); | 176 void OnSend(int result); |
183 | 177 |
184 scoped_ptr<cast_channel::Send::Params> params_; | 178 scoped_ptr<cast_channel::Send::Params> params_; |
185 | 179 |
186 FRIEND_TEST_ALL_PREFIXES(CastChannelSendFunctionTest, | |
187 TestPrepareValidMessageInfo); | |
188 FRIEND_TEST_ALL_PREFIXES(CastChannelSendFunctionTest, | |
189 TestPrepareInvalidMessageInfo); | |
190 DISALLOW_COPY_AND_ASSIGN(CastChannelSendFunction); | 180 DISALLOW_COPY_AND_ASSIGN(CastChannelSendFunction); |
191 }; | 181 }; |
192 | 182 |
193 class CastChannelCloseFunction : public CastChannelAsyncApiFunction { | 183 class CastChannelCloseFunction : public CastChannelAsyncApiFunction { |
194 public: | 184 public: |
195 CastChannelCloseFunction(); | 185 CastChannelCloseFunction(); |
196 | 186 |
197 protected: | 187 protected: |
198 virtual ~CastChannelCloseFunction(); | 188 virtual ~CastChannelCloseFunction(); |
199 | 189 |
200 // AsyncApiFunction: | 190 // AsyncApiFunction: |
201 virtual bool Prepare() OVERRIDE; | 191 virtual bool Prepare() OVERRIDE; |
202 virtual void AsyncWorkStart() OVERRIDE; | 192 virtual void AsyncWorkStart() OVERRIDE; |
203 | 193 |
204 private: | 194 private: |
205 DECLARE_EXTENSION_FUNCTION("cast.channel.close", CAST_CHANNEL_CLOSE) | 195 DECLARE_EXTENSION_FUNCTION("cast.channel.close", CAST_CHANNEL_CLOSE) |
206 | 196 |
207 void OnClose(int result); | 197 void OnClose(int result); |
208 | 198 |
209 scoped_ptr<cast_channel::Close::Params> params_; | 199 scoped_ptr<cast_channel::Close::Params> params_; |
210 | 200 |
211 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); | 201 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); |
212 }; | 202 }; |
213 | 203 |
214 } // namespace extensions | 204 } // namespace extensions |
215 | 205 |
216 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 206 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
OLD | NEW |