| 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 #include "chrome/browser/extensions/api/cast_channel/cast_channel_api.h" | 5 #include "chrome/browser/extensions/api/cast_channel/cast_channel_api.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 CastChannelAPI::CastChannelAPI(content::BrowserContext* context) | 46 CastChannelAPI::CastChannelAPI(content::BrowserContext* context) |
| 47 : browser_context_(context) { | 47 : browser_context_(context) { |
| 48 DCHECK(browser_context_); | 48 DCHECK(browser_context_); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // static | 51 // static |
| 52 CastChannelAPI* CastChannelAPI::Get(content::BrowserContext* context) { | 52 CastChannelAPI* CastChannelAPI::Get(content::BrowserContext* context) { |
| 53 return ProfileKeyedAPIFactory<CastChannelAPI>::GetForProfile(context); | 53 return BrowserContextKeyedAPIFactory<CastChannelAPI>::Get(context); |
| 54 } | 54 } |
| 55 | 55 |
| 56 static base::LazyInstance<ProfileKeyedAPIFactory<CastChannelAPI> > g_factory = | 56 static base::LazyInstance<BrowserContextKeyedAPIFactory<CastChannelAPI> > |
| 57 LAZY_INSTANCE_INITIALIZER; | 57 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 ProfileKeyedAPIFactory<CastChannelAPI>* CastChannelAPI::GetFactoryInstance() { | 60 BrowserContextKeyedAPIFactory<CastChannelAPI>* |
| 61 CastChannelAPI::GetFactoryInstance() { |
| 61 return g_factory.Pointer(); | 62 return g_factory.Pointer(); |
| 62 } | 63 } |
| 63 | 64 |
| 64 scoped_ptr<CastSocket> CastChannelAPI::CreateCastSocket( | 65 scoped_ptr<CastSocket> CastChannelAPI::CreateCastSocket( |
| 65 const std::string& extension_id, const GURL& url) { | 66 const std::string& extension_id, const GURL& url) { |
| 66 if (socket_for_test_.get()) { | 67 if (socket_for_test_.get()) { |
| 67 return socket_for_test_.Pass(); | 68 return socket_for_test_.Pass(); |
| 68 } else { | 69 } else { |
| 69 return scoped_ptr<CastSocket>( | 70 return scoped_ptr<CastSocket>( |
| 70 new CastSocket(extension_id, url, this, | 71 new CastSocket(extension_id, url, this, |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 SetResultFromError(cast_channel::CHANNEL_ERROR_SOCKET_ERROR); | 260 SetResultFromError(cast_channel::CHANNEL_ERROR_SOCKET_ERROR); |
| 260 } else { | 261 } else { |
| 261 int channel_id = params_->channel.channel_id; | 262 int channel_id = params_->channel.channel_id; |
| 262 SetResultFromSocket(channel_id); | 263 SetResultFromSocket(channel_id); |
| 263 RemoveSocket(channel_id); | 264 RemoveSocket(channel_id); |
| 264 } | 265 } |
| 265 AsyncWorkCompleted(); | 266 AsyncWorkCompleted(); |
| 266 } | 267 } |
| 267 | 268 |
| 268 } // namespace extensions | 269 } // namespace extensions |
| OLD | NEW |