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

Unified Diff: chrome/browser/ui/webui/cookies_tree_model_util.h

Issue 10703127: Merge 145197 - clean-up: Use an id instead of memory pointer string in webui. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: Created 8 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 | « no previous file | chrome/browser/ui/webui/cookies_tree_model_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/cookies_tree_model_util.h
===================================================================
--- chrome/browser/ui/webui/cookies_tree_model_util.h (revision 145933)
+++ chrome/browser/ui/webui/cookies_tree_model_util.h (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -6,8 +6,12 @@
#define CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_
#pragma once
+#include <map>
#include <string>
+#include "base/basictypes.h"
+#include "base/id_map.h"
+
class CookieTreeNode;
namespace base {
@@ -15,24 +19,43 @@
class ListValue;
}
-namespace cookies_tree_model_util {
+class CookiesTreeModelUtil {
+ public:
+ CookiesTreeModelUtil();
+ ~CookiesTreeModelUtil();
-// Returns tree node id. Currently use hex string of node pointer as id.
-std::string GetTreeNodeId(CookieTreeNode* node);
+ // Finds or creates an ID for given |node| and returns it as string.
+ std::string GetTreeNodeId(const CookieTreeNode* node);
-// Populate given |dict| with cookie tree node properties.
-// Returns false if the |node| does not need to be shown.
-bool GetCookieTreeNodeDictionary(const CookieTreeNode& node,
- base::DictionaryValue* dict);
+ // Append the children nodes of |parent| in specified range to |nodes| list.
+ void GetChildNodeList(const CookieTreeNode* parent,
+ int start,
+ int count,
+ base::ListValue* nodes);
-// Append the children nodes of |parent| in specified range to |nodes| list.
-void GetChildNodeList(CookieTreeNode* parent, int start, int count,
- base::ListValue* nodes);
+ // Gets tree node from |path| under |root|. |path| is comma separated list of
+ // ids. |id_map| translates ids into object pointers. Return NULL if |path|
+ // is not valid.
+ const CookieTreeNode* GetTreeNodeFromPath(const CookieTreeNode* root,
+ const std::string& path);
-// Gets tree node from |path| under |root|. Return NULL if |path| is not valid.
-CookieTreeNode* GetTreeNodeFromPath(CookieTreeNode* root,
- const std::string& path);
+ private:
+ typedef IDMap<const CookieTreeNode> CookiesTreeNodeIdMap;
+ typedef std::map<const CookieTreeNode*, int32> CookieTreeNodeMap;
-} // namespace cookies_tree_model_util
+ // Populate given |dict| with cookie tree node properties. |id_map| maps
+ // a CookieTreeNode to an ID and creates a new ID if |node| is not in the
+ // maps. Returns false if the |node| does not need to be shown.
+ bool GetCookieTreeNodeDictionary(const CookieTreeNode& node,
+ base::DictionaryValue* dict);
+ // IDMap to create unique ID and look up the object for an ID.
+ CookiesTreeNodeIdMap id_map_;
+
+ // Reverse look up map to find the ID for a node.
+ CookieTreeNodeMap node_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(CookiesTreeModelUtil);
+};
+
#endif // CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_
« no previous file with comments | « no previous file | chrome/browser/ui/webui/cookies_tree_model_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698