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/utility/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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 base::TaskRunner* task_runner) | 34 base::TaskRunner* task_runner) |
35 : sender_(sender), | 35 : sender_(sender), |
36 task_runner_(task_runner) { | 36 task_runner_(task_runner) { |
37 // Bridge needs to make its own copy because OS 10.6 autoreleases the | 37 // Bridge needs to make its own copy because OS 10.6 autoreleases the |
38 // localized_strings value that is passed in (see http://crbug.com/46003 ). | 38 // localized_strings value that is passed in (see http://crbug.com/46003 ). |
39 localized_strings_.reset(localized_strings.DeepCopy()); | 39 localized_strings_.reset(localized_strings.DeepCopy()); |
40 } | 40 } |
41 | 41 |
42 void ExternalProcessImporterBridge::AddBookmarks( | 42 void ExternalProcessImporterBridge::AddBookmarks( |
43 const std::vector<ImportedBookmarkEntry>& bookmarks, | 43 const std::vector<ImportedBookmarkEntry>& bookmarks, |
44 const string16& first_folder_name) { | 44 const base::string16& first_folder_name) { |
45 Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportStart( | 45 Send(new ProfileImportProcessHostMsg_NotifyBookmarksImportStart( |
46 first_folder_name, bookmarks.size())); | 46 first_folder_name, bookmarks.size())); |
47 | 47 |
48 // |bookmarks_left| is required for the checks below as Windows has a | 48 // |bookmarks_left| is required for the checks below as Windows has a |
49 // Debug bounds-check which prevents pushing an iterator beyond its end() | 49 // Debug bounds-check which prevents pushing an iterator beyond its end() |
50 // (i.e., |it + 2 < s.end()| crashes in debug mode if |i + 1 == s.end()|). | 50 // (i.e., |it + 2 < s.end()| crashes in debug mode if |i + 1 == s.end()|). |
51 int bookmarks_left = bookmarks.end() - bookmarks.begin(); | 51 int bookmarks_left = bookmarks.end() - bookmarks.begin(); |
52 for (std::vector<ImportedBookmarkEntry>::const_iterator it = | 52 for (std::vector<ImportedBookmarkEntry>::const_iterator it = |
53 bookmarks.begin(); it < bookmarks.end();) { | 53 bookmarks.begin(); it < bookmarks.end();) { |
54 std::vector<ImportedBookmarkEntry> bookmark_group; | 54 std::vector<ImportedBookmarkEntry> bookmark_group; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 | 152 |
153 void ExternalProcessImporterBridge::NotifyItemEnded(importer::ImportItem item) { | 153 void ExternalProcessImporterBridge::NotifyItemEnded(importer::ImportItem item) { |
154 Send(new ProfileImportProcessHostMsg_ImportItem_Finished(item)); | 154 Send(new ProfileImportProcessHostMsg_ImportItem_Finished(item)); |
155 } | 155 } |
156 | 156 |
157 void ExternalProcessImporterBridge::NotifyEnded() { | 157 void ExternalProcessImporterBridge::NotifyEnded() { |
158 // The internal process detects import end when all items have been received. | 158 // The internal process detects import end when all items have been received. |
159 } | 159 } |
160 | 160 |
161 string16 ExternalProcessImporterBridge::GetLocalizedString(int message_id) { | 161 base::string16 ExternalProcessImporterBridge::GetLocalizedString( |
162 string16 message; | 162 int message_id) { |
| 163 base::string16 message; |
163 localized_strings_->GetString(base::IntToString(message_id), &message); | 164 localized_strings_->GetString(base::IntToString(message_id), &message); |
164 return message; | 165 return message; |
165 } | 166 } |
166 | 167 |
167 ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {} | 168 ExternalProcessImporterBridge::~ExternalProcessImporterBridge() {} |
168 | 169 |
169 void ExternalProcessImporterBridge::Send(IPC::Message* message) { | 170 void ExternalProcessImporterBridge::Send(IPC::Message* message) { |
170 task_runner_->PostTask( | 171 task_runner_->PostTask( |
171 FROM_HERE, | 172 FROM_HERE, |
172 base::Bind(&ExternalProcessImporterBridge::SendInternal, | 173 base::Bind(&ExternalProcessImporterBridge::SendInternal, |
173 this, message)); | 174 this, message)); |
174 } | 175 } |
175 | 176 |
176 void ExternalProcessImporterBridge::SendInternal(IPC::Message* message) { | 177 void ExternalProcessImporterBridge::SendInternal(IPC::Message* message) { |
177 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 178 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
178 sender_->Send(message); | 179 sender_->Send(message); |
179 } | 180 } |
OLD | NEW |