Skip to content

Commit

Permalink
Deprecate scoped_ptr part 1.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yukawa committed Oct 25, 2015
1 parent 6a027e9 commit d56d5db
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 23 deletions.
25 changes: 13 additions & 12 deletions src/engine/engine.h
Expand Up @@ -30,8 +30,9 @@
#ifndef MOZC_ENGINE_ENGINE_H_
#define MOZC_ENGINE_ENGINE_H_

#include <memory>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "dictionary/dictionary_interface.h"
#include "dictionary/pos_group.h"
#include "dictionary/user_dictionary.h"
Expand Down Expand Up @@ -76,24 +77,24 @@ class Engine : public EngineInterface {
}

private:
scoped_ptr<dictionary::SuppressionDictionary> suppression_dictionary_;
scoped_ptr<const Connector> connector_;
scoped_ptr<const Segmenter> segmenter_;
scoped_ptr<dictionary::UserDictionary> user_dictionary_;
scoped_ptr<dictionary::DictionaryInterface> suffix_dictionary_;
scoped_ptr<dictionary::DictionaryInterface> dictionary_;
scoped_ptr<const dictionary::PosGroup> pos_group_;
scoped_ptr<ImmutableConverterInterface> immutable_converter_;
scoped_ptr<const SuggestionFilter> suggestion_filter_;
std::unique_ptr<dictionary::SuppressionDictionary> suppression_dictionary_;
std::unique_ptr<const Connector> connector_;
std::unique_ptr<const Segmenter> segmenter_;
std::unique_ptr<dictionary::UserDictionary> user_dictionary_;
std::unique_ptr<dictionary::DictionaryInterface> suffix_dictionary_;
std::unique_ptr<dictionary::DictionaryInterface> dictionary_;
std::unique_ptr<const dictionary::PosGroup> pos_group_;
std::unique_ptr<ImmutableConverterInterface> immutable_converter_;
std::unique_ptr<const SuggestionFilter> suggestion_filter_;

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

scoped_ptr<ConverterInterface> converter_;
scoped_ptr<UserDataManagerInterface> user_data_manager_;
std::unique_ptr<ConverterInterface> converter_;
std::unique_ptr<UserDataManagerInterface> user_data_manager_;

DISALLOW_COPY_AND_ASSIGN(Engine);
};
Expand Down
4 changes: 3 additions & 1 deletion src/engine/engine_factory_test.cc
Expand Up @@ -29,14 +29,16 @@

#include "engine/engine_factory.h"

#include <memory>

#include "engine/engine_interface.h"
#include "prediction/predictor_interface.h"
#include "testing/base/public/gunit.h"

namespace mozc {

TEST(EngineFactoryTest, MobilePredictorOnAndroid) {
scoped_ptr<EngineInterface> engine(EngineFactory::Create());
std::unique_ptr<EngineInterface> engine(EngineFactory::Create());
PredictorInterface *predictor = engine->GetPredictor();
#ifdef OS_ANDROID
EXPECT_EQ("MobilePredictor", predictor->GetPredictorName());
Expand Down
7 changes: 4 additions & 3 deletions src/engine/mock_converter_engine.h
Expand Up @@ -30,8 +30,9 @@
#ifndef MOZC_ENGINE_MOCK_CONVERTER_ENGINE_H_
#define MOZC_ENGINE_MOCK_CONVERTER_ENGINE_H_

#include <memory>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "engine/engine_interface.h"

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

private:
scoped_ptr<ConverterMock> converter_mock_;
scoped_ptr<UserDataManagerMock> user_data_manager_mock_;
std::unique_ptr<ConverterMock> converter_mock_;
std::unique_ptr<UserDataManagerMock> user_data_manager_mock_;

DISALLOW_COPY_AND_ASSIGN(MockConverterEngine);
};
Expand Down
2 changes: 1 addition & 1 deletion src/mozc_version_template.txt
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=17
BUILD=2146
BUILD=2147
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.
Expand Down
1 change: 1 addition & 0 deletions src/session/session_usage_observer_test.cc
Expand Up @@ -36,6 +36,7 @@
#include "base/logging.h"
#include "base/scheduler.h"
#include "base/scheduler_stub.h"
#include "base/scoped_ptr.h"
#include "base/system_util.h"
#include "base/util.h"
#include "config/stats_config_util.h"
Expand Down
1 change: 0 additions & 1 deletion src/usage_stats/usage_stats_test.cc
Expand Up @@ -33,7 +33,6 @@
#include <string>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "base/system_util.h"
#include "config/stats_config_util.h"
#include "config/stats_config_util_mock.h"
Expand Down
5 changes: 3 additions & 2 deletions src/usage_stats/usage_stats_testing_util.h
Expand Up @@ -30,8 +30,9 @@
#ifndef MOZC_USAGE_STATS_USAGE_STATS_TESTING_UTIL_H_
#define MOZC_USAGE_STATS_USAGE_STATS_TESTING_UTIL_H_

#include <memory>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "testing/base/public/gunit.h"

namespace mozc {
Expand Down Expand Up @@ -106,7 +107,7 @@ class scoped_usage_stats_enabler {
~scoped_usage_stats_enabler();

private:
scoped_ptr<mozc::config::StatsConfigUtilMock> stats_config_util_;
std::unique_ptr<mozc::config::StatsConfigUtilMock> stats_config_util_;
DISALLOW_COPY_AND_ASSIGN(scoped_usage_stats_enabler);
};

Expand Down
4 changes: 2 additions & 2 deletions src/usage_stats/usage_stats_updater.cc
Expand Up @@ -30,6 +30,7 @@
#include "usage_stats/usage_stats_updater.h"

#include <algorithm>
#include <memory>
#include <set>
#include <sstream>
#include <vector>
Expand All @@ -41,7 +42,6 @@
#include "base/mac_util.h"
#include "base/number_util.h"
#include "base/port.h"
#include "base/scoped_ptr.h"
#include "base/system_util.h"
#include "base/util.h"
#include "base/win_util.h"
Expand Down Expand Up @@ -93,7 +93,7 @@ bool IMEActivationKeyCustomized() {
for (size_t i = 0; i < arraysize(kKeyMaps); ++i) {
const char *keymap_file =
keymap::KeyMapManager::GetKeyMapFileName(kKeyMaps[i]);
scoped_ptr<istream> ifs(ConfigFileStream::LegacyOpen(keymap_file));
std::unique_ptr<istream> ifs(ConfigFileStream::LegacyOpen(keymap_file));
if (ifs.get() == NULL) {
LOG(ERROR) << "can not open default keymap table " << i;
continue;
Expand Down
1 change: 0 additions & 1 deletion src/usage_stats/usage_stats_updater_test.cc
Expand Up @@ -32,7 +32,6 @@
#include <string>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "base/system_util.h"
#include "base/util.h"
#include "config/config_handler.h"
Expand Down

0 comments on commit d56d5db

Please sign in to comment.