OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/bookmarks/bookmark_storage.h" | 5 #include "chrome/browser/bookmarks/bookmark_storage.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 JSONFileValueSerializer serializer(path_); | 62 JSONFileValueSerializer serializer(path_); |
63 scoped_ptr<Value> root(serializer.Deserialize(NULL, NULL)); | 63 scoped_ptr<Value> root(serializer.Deserialize(NULL, NULL)); |
64 | 64 |
65 if (root.get()) { | 65 if (root.get()) { |
66 // Building the index can take a while, so we do it on the background | 66 // Building the index can take a while, so we do it on the background |
67 // thread. | 67 // thread. |
68 int64 max_node_id = 0; | 68 int64 max_node_id = 0; |
69 BookmarkCodec codec; | 69 BookmarkCodec codec; |
70 TimeTicks start_time = TimeTicks::Now(); | 70 TimeTicks start_time = TimeTicks::Now(); |
71 codec.Decode(details_->bb_node(), details_->other_folder_node(), | 71 codec.Decode(details_->bb_node(), details_->other_folder_node(), |
72 &max_node_id, *root.get()); | 72 details_->synced_folder_node(), &max_node_id, *root.get()); |
73 details_->set_max_id(std::max(max_node_id, details_->max_id())); | 73 details_->set_max_id(std::max(max_node_id, details_->max_id())); |
74 details_->set_computed_checksum(codec.computed_checksum()); | 74 details_->set_computed_checksum(codec.computed_checksum()); |
75 details_->set_stored_checksum(codec.stored_checksum()); | 75 details_->set_stored_checksum(codec.stored_checksum()); |
76 details_->set_ids_reassigned(codec.ids_reassigned()); | 76 details_->set_ids_reassigned(codec.ids_reassigned()); |
77 UMA_HISTOGRAM_TIMES("Bookmarks.DecodeTime", | 77 UMA_HISTOGRAM_TIMES("Bookmarks.DecodeTime", |
78 TimeTicks::Now() - start_time); | 78 TimeTicks::Now() - start_time); |
79 | 79 |
80 start_time = TimeTicks::Now(); | 80 start_time = TimeTicks::Now(); |
81 AddBookmarksToIndex(details_->bb_node()); | 81 AddBookmarksToIndex(details_->bb_node()); |
82 AddBookmarksToIndex(details_->other_folder_node()); | 82 AddBookmarksToIndex(details_->other_folder_node()); |
| 83 AddBookmarksToIndex(details_->synced_folder_node()); |
83 UMA_HISTOGRAM_TIMES("Bookmarks.CreateBookmarkIndexTime", | 84 UMA_HISTOGRAM_TIMES("Bookmarks.CreateBookmarkIndexTime", |
84 TimeTicks::Now() - start_time); | 85 TimeTicks::Now() - start_time); |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
88 BrowserThread::PostTask( | 89 BrowserThread::PostTask( |
89 BrowserThread::UI, FROM_HERE, | 90 BrowserThread::UI, FROM_HERE, |
90 NewRunnableMethod( | 91 NewRunnableMethod( |
91 storage_.get(), &BookmarkStorage::OnLoadFinished, | 92 storage_.get(), &BookmarkStorage::OnLoadFinished, |
92 bookmark_file_exists, path_)); | 93 bookmark_file_exists, path_)); |
(...skipping 15 matching lines...) Expand all Loading... |
108 scoped_refptr<BookmarkStorage> storage_; | 109 scoped_refptr<BookmarkStorage> storage_; |
109 BookmarkLoadDetails* details_; | 110 BookmarkLoadDetails* details_; |
110 | 111 |
111 DISALLOW_COPY_AND_ASSIGN(LoadTask); | 112 DISALLOW_COPY_AND_ASSIGN(LoadTask); |
112 }; | 113 }; |
113 | 114 |
114 // BookmarkLoadDetails --------------------------------------------------------- | 115 // BookmarkLoadDetails --------------------------------------------------------- |
115 | 116 |
116 BookmarkLoadDetails::BookmarkLoadDetails(BookmarkNode* bb_node, | 117 BookmarkLoadDetails::BookmarkLoadDetails(BookmarkNode* bb_node, |
117 BookmarkNode* other_folder_node, | 118 BookmarkNode* other_folder_node, |
| 119 BookmarkNode* synced_folder_node, |
118 BookmarkIndex* index, | 120 BookmarkIndex* index, |
119 int64 max_id) | 121 int64 max_id) |
120 : bb_node_(bb_node), | 122 : bb_node_(bb_node), |
121 other_folder_node_(other_folder_node), | 123 other_folder_node_(other_folder_node), |
| 124 synced_folder_node_(synced_folder_node), |
122 index_(index), | 125 index_(index), |
123 max_id_(max_id), | 126 max_id_(max_id), |
124 ids_reassigned_(false) { | 127 ids_reassigned_(false) { |
125 } | 128 } |
126 | 129 |
127 BookmarkLoadDetails::~BookmarkLoadDetails() { | 130 BookmarkLoadDetails::~BookmarkLoadDetails() { |
128 } | 131 } |
129 | 132 |
130 // BookmarkStorage ------------------------------------------------------------- | 133 // BookmarkStorage ------------------------------------------------------------- |
131 | 134 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 NOTREACHED(); | 262 NOTREACHED(); |
260 return false; | 263 return false; |
261 } | 264 } |
262 | 265 |
263 std::string data; | 266 std::string data; |
264 if (!SerializeData(&data)) | 267 if (!SerializeData(&data)) |
265 return false; | 268 return false; |
266 writer_.WriteNow(data); | 269 writer_.WriteNow(data); |
267 return true; | 270 return true; |
268 } | 271 } |
OLD | NEW |