| 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 30 matching lines...) Expand all Loading... |
| 41 class CastChannelAPI : public BrowserContextKeyedAPI, | 41 class CastChannelAPI : public BrowserContextKeyedAPI, |
| 42 public cast_channel::CastSocket::Delegate { | 42 public cast_channel::CastSocket::Delegate { |
| 43 public: | 43 public: |
| 44 explicit CastChannelAPI(content::BrowserContext* context); | 44 explicit CastChannelAPI(content::BrowserContext* context); |
| 45 | 45 |
| 46 static CastChannelAPI* Get(content::BrowserContext* context); | 46 static CastChannelAPI* Get(content::BrowserContext* context); |
| 47 | 47 |
| 48 // BrowserContextKeyedAPI implementation. | 48 // BrowserContextKeyedAPI implementation. |
| 49 static BrowserContextKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance(); | 49 static BrowserContextKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance(); |
| 50 | 50 |
| 51 // Returns a new CastSocket that connects to |ip_endpoint| with authentication | |
| 52 // |channel_auth| and is to be owned by |extension_id|. | |
| 53 scoped_ptr<cast_channel::CastSocket> CreateCastSocket( | |
| 54 const std::string& extension_id, | |
| 55 const net::IPEndPoint& ip_endpoint, | |
| 56 cast_channel::ChannelAuthType channel_auth, | |
| 57 const base::TimeDelta& timeout); | |
| 58 | |
| 59 // Returns a pointer to the Logger member variable. | 51 // Returns a pointer to the Logger member variable. |
| 60 // TODO(imcheng): Consider whether it is possible for this class to own the | 52 // TODO(imcheng): Consider whether it is possible for this class to own the |
| 61 // CastSockets and make this class the sole owner of Logger. Alternatively, | 53 // CastSockets and make this class the sole owner of Logger. |
| 54 // Alternatively, |
| 62 // consider making Logger not ref-counted by passing a weak | 55 // consider making Logger not ref-counted by passing a weak |
| 63 // reference of Logger to the CastSockets instead. | 56 // reference of Logger to the CastSockets instead. |
| 64 scoped_refptr<cast_channel::Logger> GetLogger(); | 57 scoped_refptr<cast_channel::Logger> GetLogger(); |
| 65 | 58 |
| 66 // Sets the CastSocket instance to be returned by CreateCastSocket for | 59 // Sets the CastSocket instance to be returned by CreateCastSocket for |
| 67 // testing. | 60 // testing. |
| 68 void SetSocketForTest(scoped_ptr<cast_channel::CastSocket> socket_for_test); | 61 void SetSocketForTest(scoped_ptr<cast_channel::CastSocket> socket_for_test); |
| 69 | 62 |
| 63 // Returns a test CastSocket instance, if it is defined. |
| 64 // Otherwise returns a scoped_ptr with a NULL ptr value. |
| 65 scoped_ptr<cast_channel::CastSocket> GetSocketForTest(); |
| 66 |
| 70 private: | 67 private: |
| 71 friend class BrowserContextKeyedAPIFactory<CastChannelAPI>; | 68 friend class BrowserContextKeyedAPIFactory<CastChannelAPI>; |
| 72 friend class ::CastChannelAPITest; | 69 friend class ::CastChannelAPITest; |
| 73 | 70 |
| 74 virtual ~CastChannelAPI(); | 71 virtual ~CastChannelAPI(); |
| 75 | 72 |
| 76 // CastSocket::Delegate. Called on IO thread. | 73 // CastSocket::Delegate. Called on IO thread. |
| 77 virtual void OnError(const cast_channel::CastSocket* socket, | 74 virtual void OnError(const cast_channel::CastSocket* socket, |
| 78 cast_channel::ChannelError error_state, | 75 cast_channel::ChannelError error_state, |
| 79 const cast_channel::LastErrors& last_errors) OVERRIDE; | 76 const cast_channel::LastErrors& last_errors) OVERRIDE; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 void OnClose(int result); | 235 void OnClose(int result); |
| 239 | 236 |
| 240 CastChannelAPI* api_; | 237 CastChannelAPI* api_; |
| 241 | 238 |
| 242 DISALLOW_COPY_AND_ASSIGN(CastChannelGetLogsFunction); | 239 DISALLOW_COPY_AND_ASSIGN(CastChannelGetLogsFunction); |
| 243 }; | 240 }; |
| 244 | 241 |
| 245 } // namespace extensions | 242 } // namespace extensions |
| 246 | 243 |
| 247 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 244 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
| OLD | NEW |