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

Unified Diff: blimp/engine/common/tab_manager.h

Issue 2176733003: Add TabManager class, relocate Tab to common/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « blimp/engine/common/tab.cc ('k') | blimp/engine/common/tab_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/engine/common/tab_manager.h
diff --git a/blimp/engine/common/tab_manager.h b/blimp/engine/common/tab_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..35d0109caf2355fe6aa995fc5001ef07b685c6ad
--- /dev/null
+++ b/blimp/engine/common/tab_manager.h
@@ -0,0 +1,59 @@
+// Copyright 2016 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 BLIMP_ENGINE_COMMON_TAB_MANAGER_H_
+#define BLIMP_ENGINE_COMMON_TAB_MANAGER_H_
+
+#include <map>
+#include <memory>
+
+#include "base/containers/small_map.h"
+#include "base/macros.h"
+#include "base/observer_list.h"
+
+namespace content {
+class WebContents;
+}
+
+namespace blimp {
+namespace engine {
+
+class Tab;
+
+// Container class for tabs, which are addressable by their ID and WebContents.
+class TabManager {
+ public:
+ TabManager();
+ ~TabManager();
+
+ void Add(std::unique_ptr<Tab> tab);
+ void Remove(Tab* tab);
+ void Clear();
+
+ // Finds a tab with the ID matching |tab_id|.
+ // Returns nullptr if the tab does not exist.
+ Tab* FindTabById(int tab_id) const;
+
+ // Finds the tab which owns |contents|.
+ // Returns nullptr if such a tab does not exist.
+ Tab* FindTabByWebContents(content::WebContents* contents) const;
+
+ // Transitional method, to be used while other features are rewritten to
+ // support multiple tab IDs. Should be removed ASAP.
+ Tab* GetOnlyTab() const;
+
+ private:
+ // Map of tabs, indexed by tab ID.
+ base::SmallMap<int, std::unique_ptr<Tab>> tabs_;
+
+ // Tabs, indexed by WebContents.
+ base::SmallMap<content::WebContents*, Tab*> tabs_by_webcontents_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabManager);
+};
+
+} // namespace engine
+} // namespace blimp
+
+#endif // BLIMP_ENGINE_COMMON_TAB_MANAGER_H_
« no previous file with comments | « blimp/engine/common/tab.cc ('k') | blimp/engine/common/tab_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698