| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 friend class BrowserContextKeyedAPIFactory<CastChannelAPI>; | 68 friend class BrowserContextKeyedAPIFactory<CastChannelAPI>; |
| 69 friend class ::CastChannelAPITest; | 69 friend class ::CastChannelAPITest; |
| 70 | 70 |
| 71 virtual ~CastChannelAPI(); | 71 virtual ~CastChannelAPI(); |
| 72 | 72 |
| 73 // CastSocket::Delegate. Called on IO thread. | 73 // CastSocket::Delegate. Called on IO thread. |
| 74 virtual void OnError(const cast_channel::CastSocket* socket, | 74 virtual void OnError(const cast_channel::CastSocket* socket, |
| 75 cast_channel::ChannelError error_state, | 75 cast_channel::ChannelError error_state, |
| 76 const cast_channel::LastErrors& last_errors) OVERRIDE; | 76 const cast_channel::LastErrors& last_errors) override; |
| 77 virtual void OnMessage(const cast_channel::CastSocket* socket, | 77 virtual void OnMessage(const cast_channel::CastSocket* socket, |
| 78 const cast_channel::MessageInfo& message) OVERRIDE; | 78 const cast_channel::MessageInfo& message) override; |
| 79 | 79 |
| 80 // BrowserContextKeyedAPI implementation. | 80 // BrowserContextKeyedAPI implementation. |
| 81 static const char* service_name() { return "CastChannelAPI"; } | 81 static const char* service_name() { return "CastChannelAPI"; } |
| 82 | 82 |
| 83 content::BrowserContext* const browser_context_; | 83 content::BrowserContext* const browser_context_; |
| 84 scoped_refptr<cast_channel::Logger> logger_; | 84 scoped_refptr<cast_channel::Logger> logger_; |
| 85 scoped_ptr<cast_channel::CastSocket> socket_for_test_; | 85 scoped_ptr<cast_channel::CastSocket> socket_for_test_; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(CastChannelAPI); | 87 DISALLOW_COPY_AND_ASSIGN(CastChannelAPI); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 class CastChannelAsyncApiFunction : public AsyncApiFunction { | 90 class CastChannelAsyncApiFunction : public AsyncApiFunction { |
| 91 public: | 91 public: |
| 92 CastChannelAsyncApiFunction(); | 92 CastChannelAsyncApiFunction(); |
| 93 | 93 |
| 94 protected: | 94 protected: |
| 95 virtual ~CastChannelAsyncApiFunction(); | 95 virtual ~CastChannelAsyncApiFunction(); |
| 96 | 96 |
| 97 // AsyncApiFunction: | 97 // AsyncApiFunction: |
| 98 virtual bool PrePrepare() OVERRIDE; | 98 virtual bool PrePrepare() override; |
| 99 virtual bool Respond() OVERRIDE; | 99 virtual bool Respond() override; |
| 100 | 100 |
| 101 // Returns the socket corresponding to |channel_id| if one exists. Otherwise, | 101 // Returns the socket corresponding to |channel_id| if one exists. Otherwise, |
| 102 // sets the function result with CHANNEL_ERROR_INVALID_CHANNEL_ID, completes | 102 // sets the function result with CHANNEL_ERROR_INVALID_CHANNEL_ID, completes |
| 103 // the function, and returns null. | 103 // the function, and returns null. |
| 104 cast_channel::CastSocket* GetSocketOrCompleteWithError(int channel_id); | 104 cast_channel::CastSocket* GetSocketOrCompleteWithError(int channel_id); |
| 105 | 105 |
| 106 // Adds |socket| to |manager_| and returns the new channel_id. |manager_| | 106 // Adds |socket| to |manager_| and returns the new channel_id. |manager_| |
| 107 // assumes ownership of |socket|. | 107 // assumes ownership of |socket|. |
| 108 int AddSocket(cast_channel::CastSocket* socket); | 108 int AddSocket(cast_channel::CastSocket* socket); |
| 109 | 109 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 class CastChannelOpenFunction : public CastChannelAsyncApiFunction { | 137 class CastChannelOpenFunction : public CastChannelAsyncApiFunction { |
| 138 public: | 138 public: |
| 139 CastChannelOpenFunction(); | 139 CastChannelOpenFunction(); |
| 140 | 140 |
| 141 protected: | 141 protected: |
| 142 virtual ~CastChannelOpenFunction(); | 142 virtual ~CastChannelOpenFunction(); |
| 143 | 143 |
| 144 // AsyncApiFunction: | 144 // AsyncApiFunction: |
| 145 virtual bool PrePrepare() OVERRIDE; | 145 virtual bool PrePrepare() override; |
| 146 virtual bool Prepare() OVERRIDE; | 146 virtual bool Prepare() override; |
| 147 virtual void AsyncWorkStart() OVERRIDE; | 147 virtual void AsyncWorkStart() override; |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 DECLARE_EXTENSION_FUNCTION("cast.channel.open", CAST_CHANNEL_OPEN) | 150 DECLARE_EXTENSION_FUNCTION("cast.channel.open", CAST_CHANNEL_OPEN) |
| 151 | 151 |
| 152 // Parses the cast:// or casts:// |url|, fills |connect_info| with the | 152 // Parses the cast:// or casts:// |url|, fills |connect_info| with the |
| 153 // corresponding details, and returns true. Returns false if |url| is not a | 153 // corresponding details, and returns true. Returns false if |url| is not a |
| 154 // valid Cast URL. | 154 // valid Cast URL. |
| 155 static bool ParseChannelUrl(const GURL& url, | 155 static bool ParseChannelUrl(const GURL& url, |
| 156 cast_channel::ConnectInfo* connect_info); | 156 cast_channel::ConnectInfo* connect_info); |
| 157 | 157 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 class CastChannelSendFunction : public CastChannelAsyncApiFunction { | 178 class CastChannelSendFunction : public CastChannelAsyncApiFunction { |
| 179 public: | 179 public: |
| 180 CastChannelSendFunction(); | 180 CastChannelSendFunction(); |
| 181 | 181 |
| 182 protected: | 182 protected: |
| 183 virtual ~CastChannelSendFunction(); | 183 virtual ~CastChannelSendFunction(); |
| 184 | 184 |
| 185 // AsyncApiFunction: | 185 // AsyncApiFunction: |
| 186 virtual bool Prepare() OVERRIDE; | 186 virtual bool Prepare() override; |
| 187 virtual void AsyncWorkStart() OVERRIDE; | 187 virtual void AsyncWorkStart() override; |
| 188 | 188 |
| 189 private: | 189 private: |
| 190 DECLARE_EXTENSION_FUNCTION("cast.channel.send", CAST_CHANNEL_SEND) | 190 DECLARE_EXTENSION_FUNCTION("cast.channel.send", CAST_CHANNEL_SEND) |
| 191 | 191 |
| 192 void OnSend(int result); | 192 void OnSend(int result); |
| 193 | 193 |
| 194 scoped_ptr<cast_channel::Send::Params> params_; | 194 scoped_ptr<cast_channel::Send::Params> params_; |
| 195 | 195 |
| 196 DISALLOW_COPY_AND_ASSIGN(CastChannelSendFunction); | 196 DISALLOW_COPY_AND_ASSIGN(CastChannelSendFunction); |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 class CastChannelCloseFunction : public CastChannelAsyncApiFunction { | 199 class CastChannelCloseFunction : public CastChannelAsyncApiFunction { |
| 200 public: | 200 public: |
| 201 CastChannelCloseFunction(); | 201 CastChannelCloseFunction(); |
| 202 | 202 |
| 203 protected: | 203 protected: |
| 204 virtual ~CastChannelCloseFunction(); | 204 virtual ~CastChannelCloseFunction(); |
| 205 | 205 |
| 206 // AsyncApiFunction: | 206 // AsyncApiFunction: |
| 207 virtual bool Prepare() OVERRIDE; | 207 virtual bool Prepare() override; |
| 208 virtual void AsyncWorkStart() OVERRIDE; | 208 virtual void AsyncWorkStart() override; |
| 209 | 209 |
| 210 private: | 210 private: |
| 211 DECLARE_EXTENSION_FUNCTION("cast.channel.close", CAST_CHANNEL_CLOSE) | 211 DECLARE_EXTENSION_FUNCTION("cast.channel.close", CAST_CHANNEL_CLOSE) |
| 212 | 212 |
| 213 void OnClose(int result); | 213 void OnClose(int result); |
| 214 | 214 |
| 215 scoped_ptr<cast_channel::Close::Params> params_; | 215 scoped_ptr<cast_channel::Close::Params> params_; |
| 216 | 216 |
| 217 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); | 217 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 class CastChannelGetLogsFunction : public CastChannelAsyncApiFunction { | 220 class CastChannelGetLogsFunction : public CastChannelAsyncApiFunction { |
| 221 public: | 221 public: |
| 222 CastChannelGetLogsFunction(); | 222 CastChannelGetLogsFunction(); |
| 223 | 223 |
| 224 protected: | 224 protected: |
| 225 virtual ~CastChannelGetLogsFunction(); | 225 virtual ~CastChannelGetLogsFunction(); |
| 226 | 226 |
| 227 // AsyncApiFunction: | 227 // AsyncApiFunction: |
| 228 virtual bool PrePrepare() OVERRIDE; | 228 virtual bool PrePrepare() override; |
| 229 virtual bool Prepare() OVERRIDE; | 229 virtual bool Prepare() override; |
| 230 virtual void AsyncWorkStart() OVERRIDE; | 230 virtual void AsyncWorkStart() override; |
| 231 | 231 |
| 232 private: | 232 private: |
| 233 DECLARE_EXTENSION_FUNCTION("cast.channel.getLogs", CAST_CHANNEL_GETLOGS) | 233 DECLARE_EXTENSION_FUNCTION("cast.channel.getLogs", CAST_CHANNEL_GETLOGS) |
| 234 | 234 |
| 235 void OnClose(int result); | 235 void OnClose(int result); |
| 236 | 236 |
| 237 CastChannelAPI* api_; | 237 CastChannelAPI* api_; |
| 238 | 238 |
| 239 DISALLOW_COPY_AND_ASSIGN(CastChannelGetLogsFunction); | 239 DISALLOW_COPY_AND_ASSIGN(CastChannelGetLogsFunction); |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 } // namespace extensions | 242 } // namespace extensions |
| 243 | 243 |
| 244 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 244 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
| OLD | NEW |