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

Side by Side Diff: chrome/profile_import/profile_import_thread.cc

Issue 6979007: Many fixes to bookmark importing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Happy tests =) Created 9 years, 7 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
OLDNEW
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/profile_import/profile_import_thread.h" 5 #include "chrome/profile_import/profile_import_thread.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 IPC_MESSAGE_HANDLER(ProfileImportProcessMsg_ReportImportItemFinished, 47 IPC_MESSAGE_HANDLER(ProfileImportProcessMsg_ReportImportItemFinished,
48 OnImportItemFinished) 48 OnImportItemFinished)
49 IPC_MESSAGE_UNHANDLED(handled = false) 49 IPC_MESSAGE_UNHANDLED(handled = false)
50 IPC_END_MESSAGE_MAP() 50 IPC_END_MESSAGE_MAP()
51 return handled; 51 return handled;
52 } 52 }
53 53
54 void ProfileImportThread::OnImportStart( 54 void ProfileImportThread::OnImportStart(
55 const importer::SourceProfile& source_profile, 55 const importer::SourceProfile& source_profile,
56 uint16 items, 56 uint16 items,
57 const DictionaryValue& localized_strings, 57 const DictionaryValue& localized_strings) {
58 bool import_to_bookmark_bar) {
59 bridge_ = new ExternalProcessImporterBridge(this, localized_strings); 58 bridge_ = new ExternalProcessImporterBridge(this, localized_strings);
60 importer_ = importer::CreateImporterByType(source_profile.importer_type); 59 importer_ = importer::CreateImporterByType(source_profile.importer_type);
61 if (!importer_) { 60 if (!importer_) {
62 Send(new ProfileImportProcessHostMsg_Import_Finished(false, 61 Send(new ProfileImportProcessHostMsg_Import_Finished(false,
63 "Importer could not be created.")); 62 "Importer could not be created."));
64 return; 63 return;
65 } 64 }
66 65
67 importer_->set_import_to_bookmark_bar(import_to_bookmark_bar);
68 items_to_import_ = items; 66 items_to_import_ = items;
69 67
70 // Create worker thread in which importer runs. 68 // Create worker thread in which importer runs.
71 import_thread_.reset(new base::Thread("import_thread")); 69 import_thread_.reset(new base::Thread("import_thread"));
72 base::Thread::Options options; 70 base::Thread::Options options;
73 options.message_loop_type = MessageLoop::TYPE_IO; 71 options.message_loop_type = MessageLoop::TYPE_IO;
74 if (!import_thread_->StartWithOptions(options)) { 72 if (!import_thread_->StartWithOptions(options)) {
75 NOTREACHED(); 73 NOTREACHED();
76 Cleanup(); 74 Cleanup();
77 } 75 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 128 }
131 } 129 }
132 130
133 void ProfileImportThread::NotifyHomePageImportReady( 131 void ProfileImportThread::NotifyHomePageImportReady(
134 const GURL& home_page) { 132 const GURL& home_page) {
135 NOTIMPLEMENTED(); 133 NOTIMPLEMENTED();
136 } 134 }
137 135
138 void ProfileImportThread::NotifyBookmarksImportReady( 136 void ProfileImportThread::NotifyBookmarksImportReady(
139 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, 137 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks,
140 const string16& first_folder_name, 138 const string16& first_folder_name) {
141 int options) {
142 Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportStart( 139 Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportStart(
143 first_folder_name, options, bookmarks.size())); 140 first_folder_name, bookmarks.size()));
144 141
145 std::vector<ProfileWriter::BookmarkEntry>::const_iterator it; 142 std::vector<ProfileWriter::BookmarkEntry>::const_iterator it;
146 for (it = bookmarks.begin(); it < bookmarks.end(); 143 for (it = bookmarks.begin(); it < bookmarks.end();
147 it = it + kNumBookmarksToSend) { 144 it = it + kNumBookmarksToSend) {
148 std::vector<ProfileWriter::BookmarkEntry> bookmark_group; 145 std::vector<ProfileWriter::BookmarkEntry> bookmark_group;
149 std::vector<ProfileWriter::BookmarkEntry>::const_iterator end_group = 146 std::vector<ProfileWriter::BookmarkEntry>::const_iterator end_group =
150 it + kNumBookmarksToSend < bookmarks.end() ? 147 it + kNumBookmarksToSend < bookmarks.end() ?
151 it + kNumBookmarksToSend : bookmarks.end(); 148 it + kNumBookmarksToSend : bookmarks.end();
152 bookmark_group.assign(it, end_group); 149 bookmark_group.assign(it, end_group);
153 150
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 Send(new ProfileImportProcessHostMsg_NotifyKeywordsReady(urls, 186 Send(new ProfileImportProcessHostMsg_NotifyKeywordsReady(urls,
190 default_keyword_index, unique_on_host_and_path)); 187 default_keyword_index, unique_on_host_and_path));
191 } 188 }
192 189
193 void ProfileImportThread::Cleanup() { 190 void ProfileImportThread::Cleanup() {
194 importer_->Cancel(); 191 importer_->Cancel();
195 importer_ = NULL; 192 importer_ = NULL;
196 bridge_ = NULL; 193 bridge_ = NULL;
197 ChildProcess::current()->ReleaseProcess(); 194 ChildProcess::current()->ReleaseProcess();
198 } 195 }
OLDNEW
« no previous file with comments | « chrome/profile_import/profile_import_thread.h ('k') | chrome/test/data/safari_import/Safari/Bookmarks.plist » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698