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

Unified Diff: chrome/browser/extensions/api/copresence/copresence_api.cc

Issue 441103002: Tests for the Copresence API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@api
Patch Set: Renaming to simply CopresenceDelegate Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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..f5aee441f16675d72f39df9412bd657f832ebc71 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() {
@@ -131,8 +136,8 @@ ExtensionFunction::ResponseAction CopresenceExecuteFunction::Run() {
CopresenceService::GetFactoryInstance()->Get(browser_context());
// 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())
+ // don't have a manager, we'll create one.
+ if (!service->manager())
return RespondNow(Error(kShuttingDownMessage));
// Each execute will correspond to one ReportRequest protocol buffer.
@@ -144,7 +149,7 @@ ExtensionFunction::ResponseAction CopresenceExecuteFunction::Run() {
return RespondNow(Error(kInvalidOperationsMessage));
}
- service->client()->ExecuteReportRequest(
+ service->manager()->ExecuteReportRequest(
request,
extension_id(),
base::Bind(&CopresenceExecuteFunction::SendResult, this));

Powered by Google App Engine
This is Rietveld 408576698