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" |
11 #include "chrome/browser/extensions/api/api_function.h" | 11 #include "chrome/browser/extensions/api/api_function.h" |
12 #include "chrome/browser/extensions/api/api_resource_manager.h" | 12 #include "chrome/browser/extensions/api/api_resource_manager.h" |
13 #include "chrome/browser/extensions/api/cast_channel/cast_socket.h" | 13 #include "chrome/browser/extensions/api/cast_channel/cast_socket.h" |
14 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 14 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
15 #include "chrome/common/extensions/api/cast_channel.h" | 15 #include "chrome/common/extensions/api/cast_channel.h" |
16 #include "extensions/browser/extension_function.h" | 16 #include "extensions/browser/extension_function.h" |
17 | 17 |
18 class GURL; | 18 class GURL; |
19 class Profile; | |
20 class CastChannelAPITest; | 19 class CastChannelAPITest; |
21 | 20 |
| 21 namespace content { |
| 22 class BrowserContext; |
| 23 } |
| 24 |
22 namespace extensions { | 25 namespace extensions { |
23 | 26 |
24 namespace cast_channel = api::cast_channel; | 27 namespace cast_channel = api::cast_channel; |
25 | 28 |
26 class CastChannelAPI : public ProfileKeyedAPI, | 29 class CastChannelAPI : public ProfileKeyedAPI, |
27 public cast_channel::CastSocket::Delegate { | 30 public cast_channel::CastSocket::Delegate { |
28 | 31 |
29 public: | 32 public: |
30 explicit CastChannelAPI(Profile* profile); | 33 explicit CastChannelAPI(content::BrowserContext* context); |
31 | 34 |
32 static CastChannelAPI* Get(Profile* profile); | 35 static CastChannelAPI* Get(content::BrowserContext* context); |
33 | 36 |
34 // ProfileKeyedAPI implementation. | 37 // ProfileKeyedAPI implementation. |
35 static ProfileKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance(); | 38 static ProfileKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance(); |
36 | 39 |
37 // Returns a new CastSocket that connects to |url| and is to be owned by | 40 // Returns a new CastSocket that connects to |url| and is to be owned by |
38 // |extension_id|. | 41 // |extension_id|. |
39 scoped_ptr<cast_channel::CastSocket> CreateCastSocket( | 42 scoped_ptr<cast_channel::CastSocket> CreateCastSocket( |
40 const std::string& extension_id, const GURL& gurl); | 43 const std::string& extension_id, const GURL& gurl); |
41 | 44 |
42 // Sets the CastSocket instance to be returned by CreateCastSocket for | 45 // Sets the CastSocket instance to be returned by CreateCastSocket for |
(...skipping 10 matching lines...) Expand all Loading... |
53 virtual void OnError(const cast_channel::CastSocket* socket, | 56 virtual void OnError(const cast_channel::CastSocket* socket, |
54 cast_channel::ChannelError error) OVERRIDE; | 57 cast_channel::ChannelError error) OVERRIDE; |
55 virtual void OnMessage(const cast_channel::CastSocket* socket, | 58 virtual void OnMessage(const cast_channel::CastSocket* socket, |
56 const cast_channel::MessageInfo& message) OVERRIDE; | 59 const cast_channel::MessageInfo& message) OVERRIDE; |
57 | 60 |
58 // ProfileKeyedAPI implementation. | 61 // ProfileKeyedAPI implementation. |
59 static const char* service_name() { | 62 static const char* service_name() { |
60 return "CastChannelAPI"; | 63 return "CastChannelAPI"; |
61 } | 64 } |
62 | 65 |
63 Profile* const profile_; | 66 content::BrowserContext* const browser_context_; |
64 scoped_ptr<cast_channel::CastSocket> socket_for_test_; | 67 scoped_ptr<cast_channel::CastSocket> socket_for_test_; |
65 | 68 |
66 DISALLOW_COPY_AND_ASSIGN(CastChannelAPI); | 69 DISALLOW_COPY_AND_ASSIGN(CastChannelAPI); |
67 }; | 70 }; |
68 | 71 |
69 class CastChannelAsyncApiFunction : public AsyncApiFunction { | 72 class CastChannelAsyncApiFunction : public AsyncApiFunction { |
70 public: | 73 public: |
71 CastChannelAsyncApiFunction(); | 74 CastChannelAsyncApiFunction(); |
72 | 75 |
73 protected: | 76 protected: |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 void OnClose(int result); | 179 void OnClose(int result); |
177 | 180 |
178 scoped_ptr<cast_channel::Close::Params> params_; | 181 scoped_ptr<cast_channel::Close::Params> params_; |
179 | 182 |
180 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); | 183 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); |
181 }; | 184 }; |
182 | 185 |
183 } // namespace extensions | 186 } // namespace extensions |
184 | 187 |
185 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 188 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
OLD | NEW |