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

Side by Side Diff: chrome/browser/local_data_container.h

Issue 10536017: Refactoring CookiesTreeModel to support multiple data sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed all comments by Evan. Created 8 years, 6 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_LOCAL_DATA_CONTAINER_H_
6 #define CHROME_BROWSER_LOCAL_DATA_CONTAINER_H_
7 #pragma once
8
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/string16.h"
12 #include "chrome/browser/browsing_data_appcache_helper.h"
13 #include "chrome/browser/browsing_data_cookie_helper.h"
14 #include "chrome/browser/browsing_data_database_helper.h"
15 #include "chrome/browser/browsing_data_file_system_helper.h"
16 #include "chrome/browser/browsing_data_indexed_db_helper.h"
17 #include "chrome/browser/browsing_data_local_storage_helper.h"
18 #include "chrome/browser/browsing_data_quota_helper.h"
19 #include "chrome/browser/browsing_data_server_bound_cert_helper.h"
20 #include "net/base/server_bound_cert_store.h"
21 #include "net/cookies/cookie_monster.h"
22
23 class LocalDataContainer;
24 class CookiesTreeModelDelegate;
25
26 // Friendly typedefs for the multiple types of lists used in the model.
27 namespace {
28 typedef std::map<std::string, LocalDataContainer*> ContainerMap;
Evan Stade 2012/06/21 04:01:41 don't indent inside namespaces.
nasko 2012/06/21 16:22:12 Done.
29 typedef std::list<net::CookieMonster::CanonicalCookie> CookieList;
30 typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> DatabaseInfoList;
31 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>
32 LocalStorageInfoList;
33 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>
34 SessionStorageInfoList;
35 typedef std::list<BrowsingDataIndexedDBHelper::IndexedDBInfo>
36 IndexedDBInfoList;
37 typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo>
38 FileSystemInfoList;
39 typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoList;
40 typedef net::ServerBoundCertStore::ServerBoundCertList ServerBoundCertList;
41
42 typedef std::map<GURL, std::list<appcache::AppCacheInfo> > AppCacheInfoMap;
43 }
James Hawkins 2012/06/21 00:04:12 nit: } // namespace
nasko 2012/06/21 16:22:12 Done.
44
45 // LocalDataContainer ---------------------------------------------------------
46 // This class is a wrapper around all the BrowsingData*Helper classes. Because
47 // isolated applications have separate storage, we need different helper
48 // instances. As such, this class contains the app name and id, along with the
49 // helpers for all of the data types we need. The browser-wide "app id" will be
50 // the empty string, as no app can have empty id.
51 class LocalDataContainer {
52 public:
53 LocalDataContainer(
54 const std::string& app_name,
55 const std::string& app_id,
56 BrowsingDataCookieHelper* cookie_helper,
57 BrowsingDataDatabaseHelper* database_helper,
58 BrowsingDataLocalStorageHelper* local_storage_helper,
59 BrowsingDataLocalStorageHelper* session_storage_helper,
60 BrowsingDataAppCacheHelper* appcache_helper,
61 BrowsingDataIndexedDBHelper* indexed_db_helper,
62 BrowsingDataFileSystemHelper* file_system_helper,
63 BrowsingDataQuotaHelper* quota_helper,
64 BrowsingDataServerBoundCertHelper* server_bound_cert_helper);
65 virtual ~LocalDataContainer();
66
67 // This method must be called to start the process of fetching the resources.
68 // The delegate passed in is called back to deliver the updates.
69 void Init(CookiesTreeModelDelegate* delegate);
70
71 const std::string& app_name() { return app_name_; }
72 const std::string& app_id() { return app_id_; }
73
74 private:
75 void OnAppCacheModelInfoLoaded();
76 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list);
77 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info);
78 void OnLocalStorageModelInfoLoaded(
79 const LocalStorageInfoList& local_storage_info);
80 void OnSessionStorageModelInfoLoaded(
81 const LocalStorageInfoList& local_storage_info);
82 void OnIndexedDBModelInfoLoaded(
83 const IndexedDBInfoList& indexed_db_info);
84 void OnFileSystemModelInfoLoaded(
85 const FileSystemInfoList& file_system_info);
86 void OnQuotaModelInfoLoaded(const QuotaInfoList& quota_info);
87 void OnServerBoundCertModelInfoLoaded(const ServerBoundCertList& cert_list);
88
89 std::string app_name_;
90 std::string app_id_;
91
92 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_;
93 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_;
94 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_;
95 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_;
96 scoped_refptr<BrowsingDataLocalStorageHelper> session_storage_helper_;
97 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_;
98 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_;
99 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_;
100 scoped_refptr<BrowsingDataServerBoundCertHelper> server_bound_cert_helper_;
101
102 AppCacheInfoMap appcache_info_;
James Hawkins 2012/06/21 00:04:12 nit: This class is sorely lacking comments.
nasko 2012/06/21 16:22:12 Done.
103 CookieList cookie_list_;
104 DatabaseInfoList database_info_list_;
105 LocalStorageInfoList local_storage_info_list_;
106 LocalStorageInfoList session_storage_info_list_;
107 IndexedDBInfoList indexed_db_info_list_;
108 FileSystemInfoList file_system_info_list_;
109 QuotaInfoList quota_info_list_;
110 ServerBoundCertList server_bound_cert_list_;
111
112 // A delegate, which must outlive this object. The update callbacks use the
113 // delegate to deliver the updated data to the CookieTreeModel.
114 CookiesTreeModelDelegate* delegate_;
115
116 base::WeakPtrFactory<LocalDataContainer> weak_ptr_factory_;
117
118 friend class CookiesTreeModel;
James Hawkins 2012/06/21 00:04:12 nit: friends go at the top of the access section.
nasko 2012/06/21 16:22:12 Done.
119 friend class CookieTreeAppCacheNode;
120 friend class CookieTreeCookieNode;
121 friend class CookieTreeDatabaseNode;
122 friend class CookieTreeLocalStorageNode;
123 friend class CookieTreeSessionStorageNode;
124 friend class CookieTreeIndexedDBNode;
125 friend class CookieTreeFileSystemNode;
126 friend class CookieTreeQuotaNode;
127 friend class CookieTreeServerBoundCertNode;
128
129 DISALLOW_COPY_AND_ASSIGN(LocalDataContainer);
130 };
131
132 #endif // CHROME_BROWSER_LOCAL_DATA_CONTAINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698