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

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

Issue 11116015: bookmarks: Pass browser context pointer to BookmarkStorage instead of a pointer to Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | « chrome/browser/bookmarks/bookmark_storage.h ('k') | no next file » | 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/file_util_proxy.h"
12 #include "base/json/json_file_value_serializer.h" 11 #include "base/json/json_file_value_serializer.h"
13 #include "base/json/json_string_value_serializer.h" 12 #include "base/json/json_string_value_serializer.h"
14 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
15 #include "base/time.h" 14 #include "base/time.h"
16 #include "chrome/browser/bookmarks/bookmark_codec.h" 15 #include "chrome/browser/bookmarks/bookmark_codec.h"
17 #include "chrome/browser/bookmarks/bookmark_model.h" 16 #include "chrome/browser/bookmarks/bookmark_model.h"
18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "content/public/browser/browser_context.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 20
22 using base::TimeTicks; 21 using base::TimeTicks;
23 using content::BrowserThread; 22 using content::BrowserThread;
24 23
25 namespace { 24 namespace {
26 25
27 // Extension used for backup files (copy of main file created during startup). 26 // Extension used for backup files (copy of main file created during startup).
28 const FilePath::CharType kBackupExtension[] = FILE_PATH_LITERAL("bak"); 27 const FilePath::CharType kBackupExtension[] = FILE_PATH_LITERAL("bak");
29 28
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 index_(index), 99 index_(index),
101 max_id_(max_id), 100 max_id_(max_id),
102 ids_reassigned_(false) { 101 ids_reassigned_(false) {
103 } 102 }
104 103
105 BookmarkLoadDetails::~BookmarkLoadDetails() { 104 BookmarkLoadDetails::~BookmarkLoadDetails() {
106 } 105 }
107 106
108 // BookmarkStorage ------------------------------------------------------------- 107 // BookmarkStorage -------------------------------------------------------------
109 108
110 BookmarkStorage::BookmarkStorage(Profile* profile, BookmarkModel* model) 109 BookmarkStorage::BookmarkStorage(content::BrowserContext* context,
110 BookmarkModel* model)
111 : model_(model), 111 : model_(model),
112 writer_(profile->GetPath().Append(chrome::kBookmarksFileName), 112 writer_(context->GetPath().Append(chrome::kBookmarksFileName),
113 BrowserThread::GetMessageLoopProxyForThread( 113 BrowserThread::GetMessageLoopProxyForThread(
114 BrowserThread::FILE)) { 114 BrowserThread::FILE)) {
115 writer_.set_commit_interval(base::TimeDelta::FromMilliseconds(kSaveDelayMS)); 115 writer_.set_commit_interval(base::TimeDelta::FromMilliseconds(kSaveDelayMS));
116 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 116 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
117 base::Bind(&BackupCallback, writer_.path())); 117 base::Bind(&BackupCallback, writer_.path()));
118 } 118 }
119 119
120 BookmarkStorage::~BookmarkStorage() { 120 BookmarkStorage::~BookmarkStorage() {
121 if (writer_.HasPendingWrite()) 121 if (writer_.HasPendingWrite())
122 writer_.DoScheduledWrite(); 122 writer_.DoScheduledWrite();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 NOTREACHED(); 164 NOTREACHED();
165 return false; 165 return false;
166 } 166 }
167 167
168 std::string data; 168 std::string data;
169 if (!SerializeData(&data)) 169 if (!SerializeData(&data))
170 return false; 170 return false;
171 writer_.WriteNow(data); 171 writer_.WriteNow(data);
172 return true; 172 return true;
173 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_storage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698