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

Unified Diff: components/bookmarks/browser/bookmark_storage.cc

Issue 2883523002: Reduce the memory usage of bookmarks storage (Closed)
Patch Set: address comments and fixes. Created 3 years, 7 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 | « components/bookmarks/browser/bookmark_node.cc ('k') | components/bookmarks/browser/titled_url_index.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/bookmarks/browser/bookmark_storage.cc
diff --git a/components/bookmarks/browser/bookmark_storage.cc b/components/bookmarks/browser/bookmark_storage.cc
index d32a90c88061a8b082c770da656f63da4bdfc0a2..d7bebde71730f17062c2070d2643af020c6611d8 100644
--- a/components/bookmarks/browser/bookmark_storage.cc
+++ b/components/bookmarks/browser/bookmark_storage.cc
@@ -16,6 +16,7 @@
#include "base/json/json_string_value_serializer.h"
#include "base/metrics/histogram_macros.h"
#include "base/sequenced_task_runner.h"
+#include "base/sys_info.h"
#include "base/time/time.h"
#include "components/bookmarks/browser/bookmark_codec.h"
#include "components/bookmarks/browser/bookmark_model.h"
@@ -34,6 +35,9 @@ const base::FilePath::CharType kBackupExtension[] = FILE_PATH_LITERAL("bak");
// How often we save.
const int kSaveDelayMS = 2500;
+// Optional keys present in MetaInfo maps in bookmark nodes to load in memory.
+const char* const kOptionalMetakeys[] = {"imageData", "pageData"};
+
void BackupCallback(const base::FilePath& path) {
base::FilePath backup_path = path.ReplaceExtension(kBackupExtension);
base::CopyFile(path, backup_path);
@@ -69,6 +73,13 @@ void LoadCallback(const base::FilePath& path,
// thread.
int64_t max_node_id = 0;
BookmarkCodec codec;
+ // Do not load the image and page data into memory for low-end devices.
+ if (base::SysInfo::IsLowEndDevice()) {
sky 2017/05/25 02:54:03 What I was getting at with my earlier comment is t
ssid 2017/05/26 01:45:40 I think I have made changes as you suggested.
+ std::list<const char*> optional_keys(std::begin(kOptionalMetakeys),
+ std::end(kOptionalMetakeys));
+ codec.set_excluded_meta_info_keys(optional_keys);
+ }
+
TimeTicks start_time = TimeTicks::Now();
codec.Decode(details->bb_node(), details->other_folder_node(),
details->mobile_folder_node(), &max_node_id, *root.get());
« no previous file with comments | « components/bookmarks/browser/bookmark_node.cc ('k') | components/bookmarks/browser/titled_url_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698