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_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 BookmarkLoadDetails::~BookmarkLoadDetails() { | 105 BookmarkLoadDetails::~BookmarkLoadDetails() { |
106 } | 106 } |
107 | 107 |
108 // BookmarkStorage ------------------------------------------------------------- | 108 // BookmarkStorage ------------------------------------------------------------- |
109 | 109 |
110 BookmarkStorage::BookmarkStorage(content::BrowserContext* context, | 110 BookmarkStorage::BookmarkStorage(content::BrowserContext* context, |
111 BookmarkModel* model) | 111 BookmarkModel* model) |
112 : model_(model), | 112 : model_(model), |
113 writer_(context->GetPath().Append(chrome::kBookmarksFileName), | 113 writer_(context->GetPath().Append(chrome::kBookmarksFileName), |
114 BrowserThread::GetMessageLoopProxyForThread( | 114 BrowserThread::GetMessageLoopProxyForThread( |
115 BrowserThread::FILE)) { | 115 BrowserThread::FILE).get()) { |
116 writer_.set_commit_interval(base::TimeDelta::FromMilliseconds(kSaveDelayMS)); | 116 writer_.set_commit_interval(base::TimeDelta::FromMilliseconds(kSaveDelayMS)); |
117 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 117 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
118 base::Bind(&BackupCallback, writer_.path())); | 118 base::Bind(&BackupCallback, writer_.path())); |
119 } | 119 } |
120 | 120 |
121 BookmarkStorage::~BookmarkStorage() { | 121 BookmarkStorage::~BookmarkStorage() { |
122 if (writer_.HasPendingWrite()) | 122 if (writer_.HasPendingWrite()) |
123 writer_.DoScheduledWrite(); | 123 writer_.DoScheduledWrite(); |
124 } | 124 } |
125 | 125 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 NOTREACHED(); | 165 NOTREACHED(); |
166 return false; | 166 return false; |
167 } | 167 } |
168 | 168 |
169 std::string data; | 169 std::string data; |
170 if (!SerializeData(&data)) | 170 if (!SerializeData(&data)) |
171 return false; | 171 return false; |
172 writer_.WriteNow(data); | 172 writer_.WriteNow(data); |
173 return true; | 173 return true; |
174 } | 174 } |
OLD | NEW |