Skip to content

Commit d56d5db

Browse files
committed
Deprecate scoped_ptr part 1.
With this CL, scoped_ptr is replaced with std::unique_ptr mainly in the following directories. - src/engine/ - src/usage_stats/ BUG=#219 TEST=unittest REF_BUG=9164610 REF_CL=84942345,84942768,84943699
1 parent 6a027e9 commit d56d5db

9 files changed

+27
-23
lines changed

src/engine/engine.h

+13-12
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
#ifndef MOZC_ENGINE_ENGINE_H_
3131
#define MOZC_ENGINE_ENGINE_H_
3232

33+
#include <memory>
34+
3335
#include "base/port.h"
34-
#include "base/scoped_ptr.h"
3536
#include "dictionary/dictionary_interface.h"
3637
#include "dictionary/pos_group.h"
3738
#include "dictionary/user_dictionary.h"
@@ -76,24 +77,24 @@ class Engine : public EngineInterface {
7677
}
7778

7879
private:
79-
scoped_ptr<dictionary::SuppressionDictionary> suppression_dictionary_;
80-
scoped_ptr<const Connector> connector_;
81-
scoped_ptr<const Segmenter> segmenter_;
82-
scoped_ptr<dictionary::UserDictionary> user_dictionary_;
83-
scoped_ptr<dictionary::DictionaryInterface> suffix_dictionary_;
84-
scoped_ptr<dictionary::DictionaryInterface> dictionary_;
85-
scoped_ptr<const dictionary::PosGroup> pos_group_;
86-
scoped_ptr<ImmutableConverterInterface> immutable_converter_;
87-
scoped_ptr<const SuggestionFilter> suggestion_filter_;
80+
std::unique_ptr<dictionary::SuppressionDictionary> suppression_dictionary_;
81+
std::unique_ptr<const Connector> connector_;
82+
std::unique_ptr<const Segmenter> segmenter_;
83+
std::unique_ptr<dictionary::UserDictionary> user_dictionary_;
84+
std::unique_ptr<dictionary::DictionaryInterface> suffix_dictionary_;
85+
std::unique_ptr<dictionary::DictionaryInterface> dictionary_;
86+
std::unique_ptr<const dictionary::PosGroup> pos_group_;
87+
std::unique_ptr<ImmutableConverterInterface> immutable_converter_;
88+
std::unique_ptr<const SuggestionFilter> suggestion_filter_;
8889

8990
// TODO(noriyukit): Currently predictor and rewriter are created by this class
9091
// but owned by converter_. Since this class creates these two, it'd be better
9192
// if Engine class owns these two instances.
9293
PredictorInterface *predictor_;
9394
RewriterInterface *rewriter_;
9495

95-
scoped_ptr<ConverterInterface> converter_;
96-
scoped_ptr<UserDataManagerInterface> user_data_manager_;
96+
std::unique_ptr<ConverterInterface> converter_;
97+
std::unique_ptr<UserDataManagerInterface> user_data_manager_;
9798

9899
DISALLOW_COPY_AND_ASSIGN(Engine);
99100
};

src/engine/engine_factory_test.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@
2929

3030
#include "engine/engine_factory.h"
3131

32+
#include <memory>
33+
3234
#include "engine/engine_interface.h"
3335
#include "prediction/predictor_interface.h"
3436
#include "testing/base/public/gunit.h"
3537

3638
namespace mozc {
3739

3840
TEST(EngineFactoryTest, MobilePredictorOnAndroid) {
39-
scoped_ptr<EngineInterface> engine(EngineFactory::Create());
41+
std::unique_ptr<EngineInterface> engine(EngineFactory::Create());
4042
PredictorInterface *predictor = engine->GetPredictor();
4143
#ifdef OS_ANDROID
4244
EXPECT_EQ("MobilePredictor", predictor->GetPredictorName());

src/engine/mock_converter_engine.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
#ifndef MOZC_ENGINE_MOCK_CONVERTER_ENGINE_H_
3131
#define MOZC_ENGINE_MOCK_CONVERTER_ENGINE_H_
3232

33+
#include <memory>
34+
3335
#include "base/port.h"
34-
#include "base/scoped_ptr.h"
3536
#include "engine/engine_interface.h"
3637

3738
namespace mozc {
@@ -58,8 +59,8 @@ class MockConverterEngine : public EngineInterface {
5859
ConverterMock* mutable_converter_mock();
5960

6061
private:
61-
scoped_ptr<ConverterMock> converter_mock_;
62-
scoped_ptr<UserDataManagerMock> user_data_manager_mock_;
62+
std::unique_ptr<ConverterMock> converter_mock_;
63+
std::unique_ptr<UserDataManagerMock> user_data_manager_mock_;
6364

6465
DISALLOW_COPY_AND_ASSIGN(MockConverterEngine);
6566
};

src/mozc_version_template.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MAJOR=2
22
MINOR=17
3-
BUILD=2146
3+
BUILD=2147
44
REVISION=102
55
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
66
# downloaded by NaCl Mozc.

src/session/session_usage_observer_test.cc

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "base/logging.h"
3737
#include "base/scheduler.h"
3838
#include "base/scheduler_stub.h"
39+
#include "base/scoped_ptr.h"
3940
#include "base/system_util.h"
4041
#include "base/util.h"
4142
#include "config/stats_config_util.h"

src/usage_stats/usage_stats_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <string>
3434

3535
#include "base/port.h"
36-
#include "base/scoped_ptr.h"
3736
#include "base/system_util.h"
3837
#include "config/stats_config_util.h"
3938
#include "config/stats_config_util_mock.h"

src/usage_stats/usage_stats_testing_util.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
#ifndef MOZC_USAGE_STATS_USAGE_STATS_TESTING_UTIL_H_
3131
#define MOZC_USAGE_STATS_USAGE_STATS_TESTING_UTIL_H_
3232

33+
#include <memory>
34+
3335
#include "base/port.h"
34-
#include "base/scoped_ptr.h"
3536
#include "testing/base/public/gunit.h"
3637

3738
namespace mozc {
@@ -106,7 +107,7 @@ class scoped_usage_stats_enabler {
106107
~scoped_usage_stats_enabler();
107108

108109
private:
109-
scoped_ptr<mozc::config::StatsConfigUtilMock> stats_config_util_;
110+
std::unique_ptr<mozc::config::StatsConfigUtilMock> stats_config_util_;
110111
DISALLOW_COPY_AND_ASSIGN(scoped_usage_stats_enabler);
111112
};
112113

src/usage_stats/usage_stats_updater.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "usage_stats/usage_stats_updater.h"
3131

3232
#include <algorithm>
33+
#include <memory>
3334
#include <set>
3435
#include <sstream>
3536
#include <vector>
@@ -41,7 +42,6 @@
4142
#include "base/mac_util.h"
4243
#include "base/number_util.h"
4344
#include "base/port.h"
44-
#include "base/scoped_ptr.h"
4545
#include "base/system_util.h"
4646
#include "base/util.h"
4747
#include "base/win_util.h"
@@ -93,7 +93,7 @@ bool IMEActivationKeyCustomized() {
9393
for (size_t i = 0; i < arraysize(kKeyMaps); ++i) {
9494
const char *keymap_file =
9595
keymap::KeyMapManager::GetKeyMapFileName(kKeyMaps[i]);
96-
scoped_ptr<istream> ifs(ConfigFileStream::LegacyOpen(keymap_file));
96+
std::unique_ptr<istream> ifs(ConfigFileStream::LegacyOpen(keymap_file));
9797
if (ifs.get() == NULL) {
9898
LOG(ERROR) << "can not open default keymap table " << i;
9999
continue;

src/usage_stats/usage_stats_updater_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <string>
3333

3434
#include "base/port.h"
35-
#include "base/scoped_ptr.h"
3635
#include "base/system_util.h"
3736
#include "base/util.h"
3837
#include "config/config_handler.h"

0 commit comments

Comments
 (0)