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

Side by Side Diff: ui/app_list/search/dictionary_data_store.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 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 | « ui/app_list/search/dictionary_data_store.h ('k') | ui/app_list/search/history.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/app_list/search/dictionary_data_store.h" 5 #include "ui/app_list/search/dictionary_data_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
11 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 #include "base/task_runner_util.h" 16 #include "base/task_runner_util.h"
16 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 19
19 namespace app_list { 20 namespace app_list {
20 21
21 DictionaryDataStore::DictionaryDataStore(const base::FilePath& data_file, 22 DictionaryDataStore::DictionaryDataStore(const base::FilePath& data_file,
22 base::SequencedWorkerPool* worker_pool) 23 base::SequencedWorkerPool* worker_pool)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 file_task_runner_.get(), 57 file_task_runner_.get(),
57 FROM_HERE, 58 FROM_HERE,
58 base::Bind(&DictionaryDataStore::LoadOnBlockingPool, this), 59 base::Bind(&DictionaryDataStore::LoadOnBlockingPool, this),
59 on_loaded); 60 on_loaded);
60 } 61 }
61 62
62 void DictionaryDataStore::ScheduleWrite() { 63 void DictionaryDataStore::ScheduleWrite() {
63 writer_->ScheduleWrite(this); 64 writer_->ScheduleWrite(this);
64 } 65 }
65 66
66 scoped_ptr<base::DictionaryValue> DictionaryDataStore::LoadOnBlockingPool() { 67 std::unique_ptr<base::DictionaryValue>
68 DictionaryDataStore::LoadOnBlockingPool() {
67 DCHECK(worker_pool_->RunsTasksOnCurrentThread()); 69 DCHECK(worker_pool_->RunsTasksOnCurrentThread());
68 70
69 int error_code = JSONFileValueDeserializer::JSON_NO_ERROR; 71 int error_code = JSONFileValueDeserializer::JSON_NO_ERROR;
70 std::string error_message; 72 std::string error_message;
71 JSONFileValueDeserializer deserializer(data_file_); 73 JSONFileValueDeserializer deserializer(data_file_);
72 scoped_ptr<base::DictionaryValue> dict_value = base::DictionaryValue::From( 74 std::unique_ptr<base::DictionaryValue> dict_value =
73 deserializer.Deserialize(&error_code, &error_message)); 75 base::DictionaryValue::From(
76 deserializer.Deserialize(&error_code, &error_message));
74 if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !dict_value) { 77 if (error_code != JSONFileValueDeserializer::JSON_NO_ERROR || !dict_value) {
75 return nullptr; 78 return nullptr;
76 } 79 }
77 80
78 scoped_ptr<base::DictionaryValue> return_dict = 81 std::unique_ptr<base::DictionaryValue> return_dict =
79 make_scoped_ptr(dict_value.get()->DeepCopy()); 82 base::WrapUnique(dict_value.get()->DeepCopy());
80 cached_dict_ = std::move(dict_value); 83 cached_dict_ = std::move(dict_value);
81 return return_dict; 84 return return_dict;
82 } 85 }
83 86
84 bool DictionaryDataStore::SerializeData(std::string* data) { 87 bool DictionaryDataStore::SerializeData(std::string* data) {
85 JSONStringValueSerializer serializer(data); 88 JSONStringValueSerializer serializer(data);
86 serializer.set_pretty_print(true); 89 serializer.set_pretty_print(true);
87 return serializer.Serialize(*cached_dict_.get()); 90 return serializer.Serialize(*cached_dict_.get());
88 } 91 }
89 92
90 } // namespace app_list 93 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/search/dictionary_data_store.h ('k') | ui/app_list/search/history.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698