summaryrefslogtreecommitdiffstats
path: root/ios/web/active_state_manager_impl.h
diff options
context:
space:
mode:
authorshreyasv <shreyasv@chromium.org>2015-05-26 13:21:42 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-26 20:22:33 +0000
commite8d5f06c55e434ab6707157e0359265f14e240a3 (patch)
tree979c97b022b22af2e878c08b305b77e8ad56576c /ios/web/active_state_manager_impl.h
parentdd358bef4bad57d339ff28a666be33ab1f3d1a4b (diff)
downloadchromium_src-e8d5f06c55e434ab6707157e0359265f14e240a3.zip
chromium_src-e8d5f06c55e434ab6707157e0359265f14e240a3.tar.gz
chromium_src-e8d5f06c55e434ab6707157e0359265f14e240a3.tar.bz2
Adding the basic class outline for modal data partitioning
ActiveStateManager, CRWBrowsingDataStore, BrowsingDataPartition are public interfaces -- for use outside of web. ActiveStateManager has a concept of "active" state. At most one ActiveStateManager can be active at a given time. ActiveStateManager and BrowsingDataParition have a 1:1 relationship with BrowserState. Also renamed browser_state.cc to browser_state.mm Look at the corresponding bugs for the design doc. BUG=480654, 480507 Review URL: https://codereview.chromium.org/1138083004 Cr-Commit-Position: refs/heads/master@{#331418}
Diffstat (limited to 'ios/web/active_state_manager_impl.h')
-rw-r--r--ios/web/active_state_manager_impl.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/ios/web/active_state_manager_impl.h b/ios/web/active_state_manager_impl.h
new file mode 100644
index 0000000..05efd40
--- /dev/null
+++ b/ios/web/active_state_manager_impl.h
@@ -0,0 +1,58 @@
+// Copyright 2015 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.
+
+#ifndef IOS_WEB_ACTIVE_STATE_MANAGER_IMPL_H_
+#define IOS_WEB_ACTIVE_STATE_MANAGER_IMPL_H_
+
+#include "base/macros.h"
+#include "base/observer_list.h"
+#include "base/supports_user_data.h"
+#include "ios/web/public/active_state_manager.h"
+
+namespace web {
+
+class BrowserState;
+
+// Concrete subclass of web::ActiveStateManager. Informs observers when an
+// ActiveStateManager becomes active/inactive.
+class ActiveStateManagerImpl : public ActiveStateManager,
+ public base::SupportsUserData::Data {
+ public:
+ explicit ActiveStateManagerImpl(BrowserState* browser_state);
+ ~ActiveStateManagerImpl() override;
+
+ // ActiveStateManager methods.
+ void SetActive(bool active) override;
+ bool IsActive() override;
+
+ // Observer that is notified when a ActiveStateManager becomes active,
+ // inactive or destroyed.
+ class Observer {
+ public:
+ // Called when the ActiveStateManager becomes active.
+ virtual void OnActive() = 0;
+ // Called when the ActiveStateManager becomes inactive.
+ virtual void OnInactive() = 0;
+ // Called just before the ActiveStateManager is destroyed.
+ virtual void WillBeDestroyed() = 0;
+ };
+ // Adds an observer for this class. An observer should not be added more
+ // than once. The caller retains the ownership of the observer object.
+ void AddObserver(Observer* obs);
+ // Removes an observer.
+ void RemoveObserver(Observer* obs);
+
+ private:
+ BrowserState* browser_state_; // weak, owns this object.
+ // true if the ActiveStateManager is active.
+ bool active_;
+ // The list of observers.
+ ObserverList<Observer> observer_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActiveStateManagerImpl);
+};
+
+} // namespace web
+
+#endif // IOS_WEB_ACTIVE_STATE_MANAGER_IMPL_H_