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

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

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

Powered by Google App Engine
This is Rietveld 408576698