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

Unified Diff: chrome/browser/importer/importer.cc

Issue 242119: Attempt at fixing crash during importing. As far as I can tell from... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/importer/importer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/importer/importer.cc
===================================================================
--- chrome/browser/importer/importer.cc (revision 28120)
+++ chrome/browser/importer/importer.cc (working copy)
@@ -397,11 +397,13 @@
// ImporterHost.
ImporterHost::ImporterHost()
- : observer_(NULL),
+ : profile_(NULL),
+ observer_(NULL),
task_(NULL),
importer_(NULL),
file_loop_(g_browser_process->file_thread()->message_loop()),
waiting_for_bookmarkbar_model_(false),
+ installed_bookmark_observer_(false),
is_source_readable_(true),
headless_(false),
parent_window_(NULL) {
@@ -409,11 +411,13 @@
}
ImporterHost::ImporterHost(MessageLoop* file_loop)
- : observer_(NULL),
+ : profile_(NULL),
+ observer_(NULL),
task_(NULL),
importer_(NULL),
file_loop_(file_loop),
waiting_for_bookmarkbar_model_(false),
+ installed_bookmark_observer_(false),
is_source_readable_(true),
headless_(false),
parent_window_(NULL) {
@@ -423,12 +427,18 @@
ImporterHost::~ImporterHost() {
if (NULL != importer_)
importer_->Release();
+ if (installed_bookmark_observer_) {
+ DCHECK(profile_); // Only way for waiting_for_bookmarkbar_model_ to be true
+ // is if we have a profile.
+ profile_->GetBookmarkModel()->RemoveObserver(this);
+ }
}
void ImporterHost::Loaded(BookmarkModel* model) {
DCHECK(model->IsLoaded());
model->RemoveObserver(this);
waiting_for_bookmarkbar_model_ = false;
+ installed_bookmark_observer_ = false;
std::vector<GURL> starred_urls;
model->GetBookmarks(&starred_urls);
@@ -436,6 +446,10 @@
InvokeTaskIfDone();
}
+void ImporterHost::BookmarkModelBeingDeleted(BookmarkModel* model) {
+ installed_bookmark_observer_ = false;
+}
+
void ImporterHost::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -487,6 +501,9 @@
uint16 items,
ProfileWriter* writer,
bool first_run) {
+ DCHECK(!profile_); // We really only support importing from one host at a
+ // time.
+ profile_ = target_profile;
// Preserves the observer and creates a task, since we do async import
// so that it doesn't block the UI. When the import is complete, observer
// will be notified.
@@ -564,6 +581,7 @@
if ((items & FAVORITES) && !writer_->BookmarkModelIsLoaded()) {
target_profile->GetBookmarkModel()->AddObserver(this);
waiting_for_bookmarkbar_model_ = true;
+ installed_bookmark_observer_ = true;
}
// Observes the TemplateURLModel if needed to import search engines from the
« no previous file with comments | « chrome/browser/importer/importer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698