| 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/bind.h" |
| 7 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 8 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 9 #include "base/file_util_proxy.h" | |
| 10 #include "base/json/json_value_serializer.h" | 10 #include "base/json/json_value_serializer.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_codec.h" | 13 #include "chrome/browser/bookmarks/bookmark_codec.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 19 #include "content/common/notification_source.h" | 19 #include "content/common/notification_source.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 return; | 226 return; |
| 227 | 227 |
| 228 model_->DoneLoading(details_.release()); | 228 model_->DoneLoading(details_.release()); |
| 229 | 229 |
| 230 if (path == tmp_history_path_) { | 230 if (path == tmp_history_path_) { |
| 231 // We just finished migration from history. Save now to new file, | 231 // We just finished migration from history. Save now to new file, |
| 232 // after the model is created and done loading. | 232 // after the model is created and done loading. |
| 233 SaveNow(); | 233 SaveNow(); |
| 234 | 234 |
| 235 // Clean up after migration from history. | 235 // Clean up after migration from history. |
| 236 base::FileUtilProxy::Delete( | 236 BrowserThread::PostTask( |
| 237 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 237 BrowserThread::FILE, FROM_HERE, |
| 238 tmp_history_path_, | 238 base::IgnoreReturn(base::Callback<bool(void)>( |
| 239 false, | 239 base::Bind(&file_util::Delete, tmp_history_path_, false)))); |
| 240 NULL); | |
| 241 } | 240 } |
| 242 } | 241 } |
| 243 | 242 |
| 244 void BookmarkStorage::Observe(int type, | 243 void BookmarkStorage::Observe(int type, |
| 245 const NotificationSource& source, | 244 const NotificationSource& source, |
| 246 const NotificationDetails& details) { | 245 const NotificationDetails& details) { |
| 247 switch (type) { | 246 switch (type) { |
| 248 case chrome::NOTIFICATION_HISTORY_LOADED: | 247 case chrome::NOTIFICATION_HISTORY_LOADED: |
| 249 OnHistoryFinishedWriting(); | 248 OnHistoryFinishedWriting(); |
| 250 break; | 249 break; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 262 NOTREACHED(); | 261 NOTREACHED(); |
| 263 return false; | 262 return false; |
| 264 } | 263 } |
| 265 | 264 |
| 266 std::string data; | 265 std::string data; |
| 267 if (!SerializeData(&data)) | 266 if (!SerializeData(&data)) |
| 268 return false; | 267 return false; |
| 269 writer_.WriteNow(data); | 268 writer_.WriteNow(data); |
| 270 return true; | 269 return true; |
| 271 } | 270 } |
| OLD | NEW |