Chromium Code Reviews| Index: chrome/browser/extensions/api/copresence/copresence_api.cc |
| diff --git a/chrome/browser/extensions/api/copresence/copresence_api.cc b/chrome/browser/extensions/api/copresence/copresence_api.cc |
| index c5a3f5177dc16ff2c60ebac8ae292c2aa250ca1b..d37c34d9375fb51fa1733db3d39e345c51beb98f 100644 |
| --- a/chrome/browser/extensions/api/copresence/copresence_api.cc |
| +++ b/chrome/browser/extensions/api/copresence/copresence_api.cc |
| @@ -12,7 +12,7 @@ |
| #include "components/copresence/proto/data.pb.h" |
| #include "components/copresence/proto/enums.pb.h" |
| #include "components/copresence/proto/rpcs.pb.h" |
| -#include "components/copresence/public/copresence_client.h" |
| +#include "components/copresence/public/copresence_manager.h" |
| #include "components/copresence/public/whispernet_client.h" |
| #include "content/public/browser/browser_context.h" |
| #include "extensions/browser/event_router.h" |
| @@ -37,10 +37,10 @@ CopresenceService::CopresenceService(content::BrowserContext* context) |
| CopresenceService::~CopresenceService() {} |
| -copresence::CopresenceClient* CopresenceService::client() { |
| - if (!client_ && !is_shutting_down_) |
| - client_.reset(new copresence::CopresenceClient(this)); |
| - return client_.get(); |
| +copresence::CopresenceManager* CopresenceService::manager() { |
| + if (!manager_ && !is_shutting_down_) |
| + manager_ = copresence::CopresenceManager::Create(this); |
| + return manager_.get(); |
| } |
| copresence::WhispernetClient* CopresenceService::whispernet_client() { |
| @@ -51,10 +51,15 @@ copresence::WhispernetClient* CopresenceService::whispernet_client() { |
| void CopresenceService::Shutdown() { |
| is_shutting_down_ = true; |
| - client_.reset(); |
| + manager_.reset(); |
| whispernet_client_.reset(); |
| } |
| +void CopresenceService::set_manager_for_testing( |
| + scoped_ptr<copresence::CopresenceManager> manager) { |
| + manager_ = manager.Pass(); |
| +} |
| + |
| // static |
| BrowserContextKeyedAPIFactory<CopresenceService>* |
| CopresenceService::GetFactoryInstance() { |
| @@ -118,6 +123,7 @@ copresence::WhispernetClient* CopresenceService::GetWhispernetClient() { |
| template <> |
| void |
| BrowserContextKeyedAPIFactory<CopresenceService>::DeclareFactoryDependencies() { |
| + DCHECK(ExtensionsBrowserClient::Get()); |
|
not at google - send to devlin
2014/08/15 22:17:02
Why this?
Charlie
2014/08/15 23:46:40
Debugging code. Removed.
|
| DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| } |
| @@ -132,7 +138,7 @@ ExtensionFunction::ResponseAction CopresenceExecuteFunction::Run() { |
| // This can only happen if we're shutting down. In all other cases, if we |
| // don't have a client, we'll create one. |
| - if (!service->client()) |
| + if (!service->manager()) |
| return RespondNow(Error(kShuttingDownMessage)); |
| // Each execute will correspond to one ReportRequest protocol buffer. |
| @@ -144,7 +150,7 @@ ExtensionFunction::ResponseAction CopresenceExecuteFunction::Run() { |
| return RespondNow(Error(kInvalidOperationsMessage)); |
| } |
| - service->client()->ExecuteReportRequest( |
| + service->manager()->ExecuteReportRequest( |
| request, |
| extension_id(), |
| base::Bind(&CopresenceExecuteFunction::SendResult, this)); |