OLD | NEW |
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_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Extension used for backup files (copy of main file created during startup). | 28 // Extension used for backup files (copy of main file created during startup). |
29 const base::FilePath::CharType kBackupExtension[] = FILE_PATH_LITERAL("bak"); | 29 const base::FilePath::CharType kBackupExtension[] = FILE_PATH_LITERAL("bak"); |
30 | 30 |
31 // How often we save. | 31 // How often we save. |
32 const int kSaveDelayMS = 2500; | 32 const int kSaveDelayMS = 2500; |
33 | 33 |
34 void BackupCallback(const base::FilePath& path) { | 34 void BackupCallback(const base::FilePath& path) { |
35 base::FilePath backup_path = path.ReplaceExtension(kBackupExtension); | 35 base::FilePath backup_path = path.ReplaceExtension(kBackupExtension); |
36 file_util::CopyFile(path, backup_path); | 36 base::CopyFile(path, backup_path); |
37 } | 37 } |
38 | 38 |
39 // Adds node to the model's index, recursing through all children as well. | 39 // Adds node to the model's index, recursing through all children as well. |
40 void AddBookmarksToIndex(BookmarkLoadDetails* details, | 40 void AddBookmarksToIndex(BookmarkLoadDetails* details, |
41 BookmarkNode* node) { | 41 BookmarkNode* node) { |
42 if (node->is_url()) { | 42 if (node->is_url()) { |
43 if (node->url().is_valid()) | 43 if (node->url().is_valid()) |
44 details->index()->Add(node); | 44 details->index()->Add(node); |
45 } else { | 45 } else { |
46 for (int i = 0; i < node->child_count(); ++i) | 46 for (int i = 0; i < node->child_count(); ++i) |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 NOTREACHED(); | 173 NOTREACHED(); |
174 return false; | 174 return false; |
175 } | 175 } |
176 | 176 |
177 std::string data; | 177 std::string data; |
178 if (!SerializeData(&data)) | 178 if (!SerializeData(&data)) |
179 return false; | 179 return false; |
180 writer_.WriteNow(data); | 180 writer_.WriteNow(data); |
181 return true; | 181 return true; |
182 } | 182 } |
OLD | NEW |