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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/webui/cookies_tree_model_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_
6 #define CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_ 6 #define CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map>
9 #include <string> 10 #include <string>
10 11
12 #include "base/basictypes.h"
13 #include "base/id_map.h"
14
11 class CookieTreeNode; 15 class CookieTreeNode;
12 16
13 namespace base { 17 namespace base {
14 class DictionaryValue; 18 class DictionaryValue;
15 class ListValue; 19 class ListValue;
16 } 20 }
17 21
18 namespace cookies_tree_model_util { 22 class CookiesTreeModelUtil {
23 public:
24 CookiesTreeModelUtil();
25 ~CookiesTreeModelUtil();
19 26
20 // Returns tree node id. Currently use hex string of node pointer as id. 27 // Finds or creates an ID for given |node| and returns it as string.
21 std::string GetTreeNodeId(CookieTreeNode* node); 28 std::string GetTreeNodeId(const CookieTreeNode* node);
22 29
23 // Populate given |dict| with cookie tree node properties. 30 // Append the children nodes of |parent| in specified range to |nodes| list.
24 // Returns false if the |node| does not need to be shown. 31 void GetChildNodeList(const CookieTreeNode* parent,
25 bool GetCookieTreeNodeDictionary(const CookieTreeNode& node, 32 int start,
26 base::DictionaryValue* dict); 33 int count,
34 base::ListValue* nodes);
27 35
28 // Append the children nodes of |parent| in specified range to |nodes| list. 36 // Gets tree node from |path| under |root|. |path| is comma separated list of
29 void GetChildNodeList(CookieTreeNode* parent, int start, int count, 37 // ids. |id_map| translates ids into object pointers. Return NULL if |path|
30 base::ListValue* nodes); 38 // is not valid.
39 const CookieTreeNode* GetTreeNodeFromPath(const CookieTreeNode* root,
40 const std::string& path);
31 41
32 // Gets tree node from |path| under |root|. Return NULL if |path| is not valid. 42 private:
33 CookieTreeNode* GetTreeNodeFromPath(CookieTreeNode* root, 43 typedef IDMap<const CookieTreeNode> CookiesTreeNodeIdMap;
34 const std::string& path); 44 typedef std::map<const CookieTreeNode*, int32> CookieTreeNodeMap;
35 45
36 } // namespace cookies_tree_model_util 46 // Populate given |dict| with cookie tree node properties. |id_map| maps
47 // a CookieTreeNode to an ID and creates a new ID if |node| is not in the
48 // maps. Returns false if the |node| does not need to be shown.
49 bool GetCookieTreeNodeDictionary(const CookieTreeNode& node,
50 base::DictionaryValue* dict);
51
52 // IDMap to create unique ID and look up the object for an ID.
53 CookiesTreeNodeIdMap id_map_;
54
55 // Reverse look up map to find the ID for a node.
56 CookieTreeNodeMap node_map_;
57
58 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModelUtil);
59 };
37 60
38 #endif // CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_ 61 #endif // CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_
OLDNEW
« 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