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

Side by Side Diff: chrome/browser/bookmarks/bookmark_storage.cc

Issue 11785014: Record metrics for slow startups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android/Linux Aurora compile failure Created 7 years, 11 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/chrome_browser_main.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) 2012 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 #include "chrome/browser/bookmarks/bookmark_storage.h" 5 #include "chrome/browser/bookmarks/bookmark_storage.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/json/json_file_value_serializer.h" 11 #include "base/json/json_file_value_serializer.h"
12 #include "base/json/json_string_value_serializer.h" 12 #include "base/json/json_string_value_serializer.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "chrome/browser/bookmarks/bookmark_codec.h" 15 #include "chrome/browser/bookmarks/bookmark_codec.h"
16 #include "chrome/browser/bookmarks/bookmark_model.h" 16 #include "chrome/browser/bookmarks/bookmark_model.h"
17 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/startup_metric_utils.h"
18 #include "content/public/browser/browser_context.h" 19 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 21
21 using base::TimeTicks; 22 using base::TimeTicks;
22 using content::BrowserThread; 23 using content::BrowserThread;
23 24
24 namespace { 25 namespace {
25 26
26 // Extension used for backup files (copy of main file created during startup). 27 // Extension used for backup files (copy of main file created during startup).
27 const FilePath::CharType kBackupExtension[] = FILE_PATH_LITERAL("bak"); 28 const FilePath::CharType kBackupExtension[] = FILE_PATH_LITERAL("bak");
(...skipping 14 matching lines...) Expand all
42 details->index()->Add(node); 43 details->index()->Add(node);
43 } else { 44 } else {
44 for (int i = 0; i < node->child_count(); ++i) 45 for (int i = 0; i < node->child_count(); ++i)
45 AddBookmarksToIndex(details, node->GetChild(i)); 46 AddBookmarksToIndex(details, node->GetChild(i));
46 } 47 }
47 } 48 }
48 49
49 void LoadCallback(const FilePath& path, 50 void LoadCallback(const FilePath& path,
50 BookmarkStorage* storage, 51 BookmarkStorage* storage,
51 BookmarkLoadDetails* details) { 52 BookmarkLoadDetails* details) {
53 startup_metric_utils::ScopedSlowStartupUMA
54 scoped_timer("Startup.SlowStartupBookmarksLoad");
52 bool bookmark_file_exists = file_util::PathExists(path); 55 bool bookmark_file_exists = file_util::PathExists(path);
53 if (bookmark_file_exists) { 56 if (bookmark_file_exists) {
54 JSONFileValueSerializer serializer(path); 57 JSONFileValueSerializer serializer(path);
55 scoped_ptr<Value> root(serializer.Deserialize(NULL, NULL)); 58 scoped_ptr<Value> root(serializer.Deserialize(NULL, NULL));
56 59
57 if (root.get()) { 60 if (root.get()) {
58 // Building the index can take a while, so we do it on the background 61 // Building the index can take a while, so we do it on the background
59 // thread. 62 // thread.
60 int64 max_node_id = 0; 63 int64 max_node_id = 0;
61 BookmarkCodec codec; 64 BookmarkCodec codec;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 NOTREACHED(); 172 NOTREACHED();
170 return false; 173 return false;
171 } 174 }
172 175
173 std::string data; 176 std::string data;
174 if (!SerializeData(&data)) 177 if (!SerializeData(&data))
175 return false; 178 return false;
176 writer_.WriteNow(data); 179 writer_.WriteNow(data);
177 return true; 180 return true;
178 } 181 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698