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

Unified Diff: components/offline_items_collection/core/test_support/scoped_mock_offline_content_provider.cc

Issue 2690333002: Initial checkin of OfflineContentProvider. (Closed)
Patch Set: Removed forwarding build file and targets for now Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/offline_items_collection/core/test_support/scoped_mock_offline_content_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_items_collection/core/test_support/scoped_mock_offline_content_provider.cc
diff --git a/components/offline_items_collection/core/test_support/scoped_mock_offline_content_provider.cc b/components/offline_items_collection/core/test_support/scoped_mock_offline_content_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6b3d93c9034a9df3d1fabb4085a97ce5e2e02c8c
--- /dev/null
+++ b/components/offline_items_collection/core/test_support/scoped_mock_offline_content_provider.cc
@@ -0,0 +1,41 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/offline_items_collection/core/test_support/scoped_mock_offline_content_provider.h"
+
+#include "components/offline_items_collection/core/offline_content_aggregator.h"
+#include "components/offline_items_collection/core/offline_content_provider.h"
+
+namespace offline_items_collection {
+
+ScopedMockOfflineContentProvider::ScopedMockObserver::ScopedMockObserver(
+ OfflineContentProvider* provider)
+ : provider_(provider) {
+ provider_->AddObserver(this);
+}
+
+ScopedMockOfflineContentProvider::ScopedMockObserver::~ScopedMockObserver() {
+ provider_->RemoveObserver(this);
+}
+
+ScopedMockOfflineContentProvider::ScopedMockOfflineContentProvider(
+ const std::string& name_space,
+ OfflineContentAggregator* aggregator)
+ : name_space_(name_space), aggregator_(aggregator) {
+ aggregator_->RegisterProvider(name_space_, this);
+}
+
+ScopedMockOfflineContentProvider::~ScopedMockOfflineContentProvider() {
+ Unregister();
+}
+
+void ScopedMockOfflineContentProvider::Unregister() {
+ if (!aggregator_)
+ return;
+
+ aggregator_->UnregisterProvider(name_space_);
+ aggregator_ = nullptr;
+}
+
+} // namespace offline_items_collection
« no previous file with comments | « components/offline_items_collection/core/test_support/scoped_mock_offline_content_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698