Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: chrome/browser/extensions/api/cast_channel/cast_channel_api.h

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_resource_manager.h" 11 #include "chrome/browser/extensions/api/api_resource_manager.h"
12 #include "chrome/browser/extensions/api/cast_channel/cast_socket.h" 12 #include "chrome/browser/extensions/api/cast_channel/cast_socket.h"
13 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
14 #include "chrome/common/extensions/api/cast_channel.h" 13 #include "chrome/common/extensions/api/cast_channel.h"
15 #include "extensions/browser/api/async_api_function.h" 14 #include "extensions/browser/api/async_api_function.h"
15 #include "extensions/browser/browser_context_keyed_api_factory.h"
16 16
17 class GURL; 17 class GURL;
18 class CastChannelAPITest; 18 class CastChannelAPITest;
19 19
20 namespace content { 20 namespace content {
21 class BrowserContext; 21 class BrowserContext;
22 } 22 }
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 namespace cast_channel = api::cast_channel; 26 namespace cast_channel = api::cast_channel;
27 27
28 class CastChannelAPI : public ProfileKeyedAPI, 28 class CastChannelAPI : public BrowserContextKeyedAPI,
29 public cast_channel::CastSocket::Delegate { 29 public cast_channel::CastSocket::Delegate {
30 30
31 public: 31 public:
32 explicit CastChannelAPI(content::BrowserContext* context); 32 explicit CastChannelAPI(content::BrowserContext* context);
33 33
34 static CastChannelAPI* Get(content::BrowserContext* context); 34 static CastChannelAPI* Get(content::BrowserContext* context);
35 35
36 // ProfileKeyedAPI implementation. 36 // BrowserContextKeyedAPI implementation.
37 static ProfileKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance(); 37 static BrowserContextKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance();
38 38
39 // Returns a new CastSocket that connects to |url| and is to be owned by 39 // Returns a new CastSocket that connects to |url| and is to be owned by
40 // |extension_id|. 40 // |extension_id|.
41 scoped_ptr<cast_channel::CastSocket> CreateCastSocket( 41 scoped_ptr<cast_channel::CastSocket> CreateCastSocket(
42 const std::string& extension_id, const GURL& gurl); 42 const std::string& extension_id, const GURL& gurl);
43 43
44 // Sets the CastSocket instance to be returned by CreateCastSocket for 44 // Sets the CastSocket instance to be returned by CreateCastSocket for
45 // testing. 45 // testing.
46 void SetSocketForTest(scoped_ptr<cast_channel::CastSocket> socket_for_test); 46 void SetSocketForTest(scoped_ptr<cast_channel::CastSocket> socket_for_test);
47 47
48 private: 48 private:
49 friend class ProfileKeyedAPIFactory<CastChannelAPI>; 49 friend class BrowserContextKeyedAPIFactory<CastChannelAPI>;
50 friend class ::CastChannelAPITest; 50 friend class ::CastChannelAPITest;
51 51
52 virtual ~CastChannelAPI(); 52 virtual ~CastChannelAPI();
53 53
54 // CastSocket::Delegate. Called on IO thread. 54 // CastSocket::Delegate. Called on IO thread.
55 virtual void OnError(const cast_channel::CastSocket* socket, 55 virtual void OnError(const cast_channel::CastSocket* socket,
56 cast_channel::ChannelError error) OVERRIDE; 56 cast_channel::ChannelError error) OVERRIDE;
57 virtual void OnMessage(const cast_channel::CastSocket* socket, 57 virtual void OnMessage(const cast_channel::CastSocket* socket,
58 const cast_channel::MessageInfo& message) OVERRIDE; 58 const cast_channel::MessageInfo& message) OVERRIDE;
59 59
60 // ProfileKeyedAPI implementation. 60 // BrowserContextKeyedAPI implementation.
61 static const char* service_name() { 61 static const char* service_name() {
62 return "CastChannelAPI"; 62 return "CastChannelAPI";
63 } 63 }
64 64
65 content::BrowserContext* const browser_context_; 65 content::BrowserContext* const browser_context_;
66 scoped_ptr<cast_channel::CastSocket> socket_for_test_; 66 scoped_ptr<cast_channel::CastSocket> socket_for_test_;
67 67
68 DISALLOW_COPY_AND_ASSIGN(CastChannelAPI); 68 DISALLOW_COPY_AND_ASSIGN(CastChannelAPI);
69 }; 69 };
70 70
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void OnClose(int result); 178 void OnClose(int result);
179 179
180 scoped_ptr<cast_channel::Close::Params> params_; 180 scoped_ptr<cast_channel::Close::Params> params_;
181 181
182 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); 182 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction);
183 }; 183 };
184 184
185 } // namespace extensions 185 } // namespace extensions
186 186
187 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ 187 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698