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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 // Removes the CastSocket corresponding to |channel_id| from the resource | 110 // Removes the CastSocket corresponding to |channel_id| from the resource |
111 // manager. | 111 // manager. |
112 void RemoveSocket(int channel_id); | 112 void RemoveSocket(int channel_id); |
113 | 113 |
114 // Sets the function result to a ChannelInfo obtained from the state of | 114 // Sets the function result to a ChannelInfo obtained from the state of |
115 // |socket|. | 115 // |socket|. |
116 void SetResultFromSocket(const cast_channel::CastSocket& socket); | 116 void SetResultFromSocket(const cast_channel::CastSocket& socket); |
117 | 117 |
118 // Sets the function result to a ChannelInfo populated with |channel_id| and | 118 // Sets the function result to a ChannelInfo populated with |channel_id| and |
119 // |error|. | 119 // |channel_error|. |
120 void SetResultFromError(int channel_id, cast_channel::ChannelError error); | 120 void SetResultFromError(int channel_id, |
| 121 cast_channel::ChannelError channel_error); |
| 122 |
| 123 // Sets extension lastError to |error| and function result to |channel_error|. |
| 124 void SetChannelError(const std::string& error, |
| 125 cast_channel::ChannelError channel_error = |
| 126 cast_channel::CHANNEL_ERROR_UNKNOWN); |
121 | 127 |
122 // Returns the socket corresponding to |channel_id| if one exists, or null | 128 // Returns the socket corresponding to |channel_id| if one exists, or null |
123 // otherwise. | 129 // otherwise. |
124 cast_channel::CastSocket* GetSocket(int channel_id); | 130 cast_channel::CastSocket* GetSocket(int channel_id); |
125 | 131 |
126 private: | 132 private: |
127 // Sets the function result from |channel_info|. | 133 // Sets the function result from |channel_info|. |
128 void SetResultFromChannelInfo(const cast_channel::ChannelInfo& channel_info); | 134 void SetResultFromChannelInfo(const cast_channel::ChannelInfo& channel_info); |
129 | 135 |
130 // The API resource manager for CastSockets. | 136 // The API resource manager for CastSockets. |
131 ApiResourceManager<cast_channel::CastSocket>* manager_; | 137 ApiResourceManager<cast_channel::CastSocket>* manager_; |
132 | 138 |
133 // The result of the function. | 139 // The result of the function. |
134 cast_channel::ChannelError error_; | 140 cast_channel::ChannelError channel_error_; |
135 }; | 141 }; |
136 | 142 |
137 class CastChannelOpenFunction : public CastChannelAsyncApiFunction { | 143 class CastChannelOpenFunction : public CastChannelAsyncApiFunction { |
138 public: | 144 public: |
139 CastChannelOpenFunction(); | 145 CastChannelOpenFunction(); |
140 | 146 |
141 protected: | 147 protected: |
142 ~CastChannelOpenFunction() override; | 148 ~CastChannelOpenFunction() override; |
143 | 149 |
144 // AsyncApiFunction: | 150 // AsyncApiFunction: |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 CAST_CHANNEL_SETAUTHORITYKEYS) | 259 CAST_CHANNEL_SETAUTHORITYKEYS) |
254 | 260 |
255 scoped_ptr<cast_channel::SetAuthorityKeys::Params> params_; | 261 scoped_ptr<cast_channel::SetAuthorityKeys::Params> params_; |
256 | 262 |
257 DISALLOW_COPY_AND_ASSIGN(CastChannelSetAuthorityKeysFunction); | 263 DISALLOW_COPY_AND_ASSIGN(CastChannelSetAuthorityKeysFunction); |
258 }; | 264 }; |
259 | 265 |
260 } // namespace extensions | 266 } // namespace extensions |
261 | 267 |
262 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 268 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
OLD | NEW |