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/importer/external_process_importer_bridge.h" | 5 #include "chrome/utility/importer/external_process_importer_bridge.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/common/importer/imported_bookmark_entry.h" | 13 #include "chrome/common/importer/imported_bookmark_entry.h" |
14 #include "chrome/common/importer/imported_favicon_usage.h" | 14 #include "chrome/common/importer/imported_favicon_usage.h" |
15 #include "chrome/common/importer/importer_data_types.h" | 15 #include "chrome/common/importer/importer_data_types.h" |
16 #include "chrome/common/importer/profile_import_process_messages.h" | 16 #include "chrome/common/importer/profile_import_process_messages.h" |
17 #include "content/public/common/password_form.h" | 17 #include "content/public/common/password_form.h" |
18 #include "ipc/ipc_sender.h" | 18 #include "ipc/ipc_sender.h" |
19 | 19 |
20 #if defined(OS_WIN) | |
21 #include "components/webdata/encryptor/ie7_password.h" | |
22 #endif | |
23 | |
24 namespace { | 20 namespace { |
25 | 21 |
26 // Rather than sending all import items over IPC at once we chunk them into | 22 // Rather than sending all import items over IPC at once we chunk them into |
27 // separate requests. This avoids the case of a large import causing | 23 // separate requests. This avoids the case of a large import causing |
28 // oversized IPC messages. | 24 // oversized IPC messages. |
29 const int kNumBookmarksToSend = 100; | 25 const int kNumBookmarksToSend = 100; |
30 const int kNumHistoryRowsToSend = 100; | 26 const int kNumHistoryRowsToSend = 100; |
31 const int kNumFaviconsToSend = 100; | 27 const int kNumFaviconsToSend = 100; |
32 | 28 |
33 } | 29 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 Send(new ProfileImportProcessHostMsg_NotifyFaviconsImportGroup( | 94 Send(new ProfileImportProcessHostMsg_NotifyFaviconsImportGroup( |
99 favicons_group)); | 95 favicons_group)); |
100 favicons_left -= end_group - it; | 96 favicons_left -= end_group - it; |
101 it = end_group; | 97 it = end_group; |
102 } | 98 } |
103 DCHECK_EQ(0, favicons_left); | 99 DCHECK_EQ(0, favicons_left); |
104 } | 100 } |
105 | 101 |
106 void ExternalProcessImporterBridge::SetHistoryItems( | 102 void ExternalProcessImporterBridge::SetHistoryItems( |
107 const std::vector<ImporterURLRow>& rows, | 103 const std::vector<ImporterURLRow>& rows, |
108 history::VisitSource visit_source) { | 104 ImporterVisitSource visit_source) { |
109 Send(new ProfileImportProcessHostMsg_NotifyHistoryImportStart(rows.size())); | 105 Send(new ProfileImportProcessHostMsg_NotifyHistoryImportStart(rows.size())); |
110 | 106 |
111 // |rows_left| is required for the checks below as Windows has a | 107 // |rows_left| is required for the checks below as Windows has a |
112 // Debug bounds-check which prevents pushing an iterator beyond its end() | 108 // Debug bounds-check which prevents pushing an iterator beyond its end() |
113 // (i.e., |it + 2 < s.end()| crashes in debug mode if |i + 1 == s.end()|). | 109 // (i.e., |it + 2 < s.end()| crashes in debug mode if |i + 1 == s.end()|). |
114 int rows_left = rows.end() - rows.begin(); | 110 int rows_left = rows.end() - rows.begin(); |
115 for (std::vector<ImporterURLRow>::const_iterator it = rows.begin(); | 111 for (std::vector<ImporterURLRow>::const_iterator it = rows.begin(); |
116 it < rows.end();) { | 112 it < rows.end();) { |
117 std::vector<ImporterURLRow> row_group; | 113 std::vector<ImporterURLRow> row_group; |
118 std::vector<ImporterURLRow>::const_iterator end_group = | 114 std::vector<ImporterURLRow>::const_iterator end_group = |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 task_runner_->PostTask( | 170 task_runner_->PostTask( |
175 FROM_HERE, | 171 FROM_HERE, |
176 base::Bind(&ExternalProcessImporterBridge::SendInternal, | 172 base::Bind(&ExternalProcessImporterBridge::SendInternal, |
177 this, message)); | 173 this, message)); |
178 } | 174 } |
179 | 175 |
180 void ExternalProcessImporterBridge::SendInternal(IPC::Message* message) { | 176 void ExternalProcessImporterBridge::SendInternal(IPC::Message* message) { |
181 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 177 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
182 sender_->Send(message); | 178 sender_->Send(message); |
183 } | 179 } |
OLD | NEW |