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

Side by Side Diff: chrome/utility/profile_import_handler.cc

Issue 2577563002: Add struct traits for base::Value. (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « chrome/utility/profile_import_handler.h ('k') | components/arc/common/bluetooth.mojom » ('j') | 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/utility/profile_import_handler.h" 5 #include "chrome/utility/profile_import_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 15 matching lines...) Expand all
26 // static 26 // static
27 void ProfileImportHandler::Create( 27 void ProfileImportHandler::Create(
28 mojo::InterfaceRequest<chrome::mojom::ProfileImport> request) { 28 mojo::InterfaceRequest<chrome::mojom::ProfileImport> request) {
29 mojo::MakeStrongBinding(base::MakeUnique<ProfileImportHandler>(), 29 mojo::MakeStrongBinding(base::MakeUnique<ProfileImportHandler>(),
30 std::move(request)); 30 std::move(request));
31 } 31 }
32 32
33 void ProfileImportHandler::StartImport( 33 void ProfileImportHandler::StartImport(
34 const importer::SourceProfile& source_profile, 34 const importer::SourceProfile& source_profile,
35 uint16_t items, 35 uint16_t items,
36 const base::DictionaryValue& localized_strings, 36 std::unique_ptr<base::DictionaryValue> localized_strings,
37 chrome::mojom::ProfileImportObserverPtr observer) { 37 chrome::mojom::ProfileImportObserverPtr observer) {
38 content::UtilityThread::Get()->EnsureBlinkInitialized(); 38 content::UtilityThread::Get()->EnsureBlinkInitialized();
39 importer_ = importer::CreateImporterByType(source_profile.importer_type); 39 importer_ = importer::CreateImporterByType(source_profile.importer_type);
40 if (!importer_.get()) { 40 if (!importer_.get()) {
41 observer->OnImportFinished(false, "Importer could not be created."); 41 observer->OnImportFinished(false, "Importer could not be created.");
42 return; 42 return;
43 } 43 }
44 44
45 items_to_import_ = items; 45 items_to_import_ = items;
46 46
47 // Create worker thread in which importer runs. 47 // Create worker thread in which importer runs.
48 import_thread_.reset(new base::Thread("import_thread")); 48 import_thread_.reset(new base::Thread("import_thread"));
49 #if defined(OS_WIN) 49 #if defined(OS_WIN)
50 import_thread_->init_com_with_mta(false); 50 import_thread_->init_com_with_mta(false);
51 #endif 51 #endif
52 if (!import_thread_->Start()) { 52 if (!import_thread_->Start()) {
53 NOTREACHED(); 53 NOTREACHED();
54 ImporterCleanup(); 54 ImporterCleanup();
55 } 55 }
56 bridge_ = new ExternalProcessImporterBridge( 56 bridge_ = new ExternalProcessImporterBridge(
57 localized_strings, 57 *localized_strings,
58 ThreadSafeProfileImportObserverPtr::Create(std::move(observer))); 58 ThreadSafeProfileImportObserverPtr::Create(std::move(observer)));
59 import_thread_->task_runner()->PostTask( 59 import_thread_->task_runner()->PostTask(
60 FROM_HERE, base::Bind(&Importer::StartImport, importer_, 60 FROM_HERE, base::Bind(&Importer::StartImport, importer_,
61 source_profile, items, base::RetainedRef(bridge_))); 61 source_profile, items, base::RetainedRef(bridge_)));
62 } 62 }
63 63
64 void ProfileImportHandler::CancelImport() { 64 void ProfileImportHandler::CancelImport() {
65 ImporterCleanup(); 65 ImporterCleanup();
66 } 66 }
67 67
68 void ProfileImportHandler::ReportImportItemFinished(importer::ImportItem item) { 68 void ProfileImportHandler::ReportImportItemFinished(importer::ImportItem item) {
69 items_to_import_ ^= item; // Remove finished item from mask. 69 items_to_import_ ^= item; // Remove finished item from mask.
70 if (items_to_import_ == 0) { 70 if (items_to_import_ == 0) {
71 ImporterCleanup(); 71 ImporterCleanup();
72 } 72 }
73 } 73 }
74 74
75 void ProfileImportHandler::ImporterCleanup() { 75 void ProfileImportHandler::ImporterCleanup() {
76 importer_->Cancel(); 76 importer_->Cancel();
77 importer_ = NULL; 77 importer_ = NULL;
78 bridge_ = NULL; 78 bridge_ = NULL;
79 import_thread_.reset(); 79 import_thread_.reset();
80 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); 80 content::UtilityThread::Get()->ReleaseProcessIfNeeded();
81 } 81 }
OLDNEW
« no previous file with comments | « chrome/utility/profile_import_handler.h ('k') | components/arc/common/bluetooth.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698