Skip to content

Commit

Permalink
Deprecate scoped_ptr part 3.
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/chrome/
 - src/client/
 - src/composer/
 - src/converter/
 - src/handwriting/
 - src/mac/
 - src/prediction/
 - src/renderer/
 - src/rewriter/
 - src/session/

BUG=#219
TEST=unittest
REF_BUG=9164610
REF_CL=85037361,85040383,85120717,85123903,85124773,85125239,85125883,85128985,85135671,85140884
  • Loading branch information
Noriyuki Takahashi authored and yukawa committed Oct 25, 2015
1 parent 3cbfeb2 commit 1ed3119
Show file tree
Hide file tree
Showing 117 changed files with 1,000 additions and 923 deletions.
3 changes: 1 addition & 2 deletions src/chrome/nacl/dictionary_downloader.cc
Expand Up @@ -33,9 +33,8 @@

#include "base/logging.h"
#include "base/mutex.h"
#include "base/port.h"
#include "base/pepper_file_util.h"
#include "base/scoped_ptr.h"
#include "base/port.h"
#include "base/util.h"
#include "chrome/nacl/url_loader_util.h"
#include "net/http_client_pepper.h"
Expand Down
4 changes: 2 additions & 2 deletions src/chrome/nacl/dictionary_downloader.h
Expand Up @@ -30,10 +30,10 @@
#ifndef MOZC_CHROME_NACL_DICTIONARY_DOWNLOADER_H_
#define MOZC_CHROME_NACL_DICTIONARY_DOWNLOADER_H_

#include <memory>
#include <string>

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

namespace mozc {
namespace chrome {
Expand Down Expand Up @@ -67,7 +67,7 @@ class DictionaryDownloader {

private:
class Impl;
scoped_ptr<Impl> impl_;
std::unique_ptr<Impl> impl_;
DISALLOW_COPY_AND_ASSIGN(DictionaryDownloader);
};

Expand Down
17 changes: 9 additions & 8 deletions src/chrome/nacl/nacl_net_test_module.cc
Expand Up @@ -27,12 +27,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <memory>
#include <string>

#include "base/port.h"
#include "base/util.h"
#include "base/number_util.h"
#include "base/pepper_file_util.h"
#include "base/port.h"
#include "base/util.h"
#include "chrome/nacl/dictionary_downloader.h"
#include "net/http_client.h"
#include "testing/base/public/gunit.h"
Expand Down Expand Up @@ -93,7 +94,7 @@ TEST_F(DictionaryDownloaderTest, HTTPClientRetryTest) {

TEST_F(DictionaryDownloaderTest, SimpleTest) {
SetRetryTestCounter(0);
scoped_ptr<DictionaryDownloader> downloader;
std::unique_ptr<DictionaryDownloader> downloader;
downloader.reset(new DictionaryDownloader(base_url_, "/test01"));
downloader->StartDownload();
while (downloader->GetStatus() != DictionaryDownloader::DOWNLOAD_FINISHED) {
Expand All @@ -114,7 +115,7 @@ TEST_F(DictionaryDownloaderTest, SimpleTest) {

TEST_F(DictionaryDownloaderTest, LargeDataTest) {
SetRetryTestCounter(0);
scoped_ptr<DictionaryDownloader> downloader;
std::unique_ptr<DictionaryDownloader> downloader;
downloader.reset(new DictionaryDownloader(
base_url_ + "?data=0123456789&times=1000000",
"/large_data"));
Expand All @@ -131,7 +132,7 @@ TEST_F(DictionaryDownloaderTest, LargeDataTest) {

TEST_F(DictionaryDownloaderTest, RetryTest) {
SetRetryTestCounter(-1);
scoped_ptr<DictionaryDownloader> downloader;
std::unique_ptr<DictionaryDownloader> downloader;
downloader.reset(new DictionaryDownloader(base_url_, "/test01"));
downloader->StartDownload();
while (downloader->GetStatus() != DictionaryDownloader::DOWNLOAD_ERROR) {
Expand Down Expand Up @@ -159,7 +160,7 @@ TEST_F(DictionaryDownloaderTest, RetryTest) {

TEST_F(DictionaryDownloaderTest, DelayTest) {
SetRetryTestCounter(0);
scoped_ptr<DictionaryDownloader> downloader;
std::unique_ptr<DictionaryDownloader> downloader;
downloader.reset(new DictionaryDownloader(base_url_, "/test01"));
downloader->SetOption(1000, 0, 0, 0, 0);
downloader->StartDownload();
Expand All @@ -174,7 +175,7 @@ TEST_F(DictionaryDownloaderTest, DelayTest) {

TEST_F(DictionaryDownloaderTest, RetryIntervalTest) {
SetRetryTestCounter(-3);
scoped_ptr<DictionaryDownloader> downloader;
std::unique_ptr<DictionaryDownloader> downloader;
downloader.reset(new DictionaryDownloader(base_url_, "/test01"));
downloader->SetOption(0, 0, 1000, 0, 3);
downloader->StartDownload();
Expand All @@ -198,7 +199,7 @@ TEST_F(DictionaryDownloaderTest, RetryIntervalTest) {
}

TEST_F(DictionaryDownloaderTest, RetryIntervalBackOffTest) {
scoped_ptr<DictionaryDownloader> downloader;
std::unique_ptr<DictionaryDownloader> downloader;
SetRetryTestCounter(-3);
downloader.reset(new DictionaryDownloader(base_url_, "/test01"));
downloader->SetOption(0, 0, 1000, 1, 3);
Expand Down
21 changes: 11 additions & 10 deletions src/chrome/nacl/nacl_session_handler.cc
Expand Up @@ -34,6 +34,7 @@
#include <ppapi/cpp/var.h>
#include <ppapi/utility/completion_callback_factory.h>

#include <memory>
#include <queue>
#include <string>

Expand Down Expand Up @@ -239,7 +240,7 @@ class MozcSessionHandlerThread : public Thread {

while (true) {
bool stopped = false;
scoped_ptr<Json::Value> message;
std::unique_ptr<Json::Value> message;
message.reset(message_queue_->take(&stopped));
if (stopped) {
LOG(ERROR) << " message_queue_ stopped";
Expand Down Expand Up @@ -302,7 +303,7 @@ class MozcSessionHandlerThread : public Thread {
LOG(ERROR) << "PepperFileUtil::ReadBinaryFile error";
return false;
}
scoped_ptr<mozc::packed::PackedDataManager>
std::unique_ptr<mozc::packed::PackedDataManager>
data_manager(new mozc::packed::PackedDataManager());
if (!data_manager->InitWithZippedData(buffer)) {
LOG(ERROR) << "InitWithZippedData error";
Expand Down Expand Up @@ -340,7 +341,7 @@ class MozcSessionHandlerThread : public Thread {
const string data_file_name = "./zipped_data_oss";
#endif // GOOGLE_JAPANESE_INPUT_BUILD
CHECK(HTTPClient::Get(data_file_name, option, &output));
scoped_ptr<mozc::packed::PackedDataManager>
std::unique_ptr<mozc::packed::PackedDataManager>
data_manager(new mozc::packed::PackedDataManager());
CHECK(data_manager->InitWithZippedData(output));
mozc::packed::RegisterPackedDataManager(data_manager.release());
Expand Down Expand Up @@ -405,12 +406,12 @@ class MozcSessionHandlerThread : public Thread {
pp::Instance *instance_;
BlockingQueue<Json::Value *> *message_queue_;
pp::CompletionCallbackFactory<MozcSessionHandlerThread> factory_;
scoped_ptr<EngineInterface> engine_;
scoped_ptr<SessionHandlerInterface> handler_;
scoped_ptr<const UserPOSInterface> user_pos_;
std::unique_ptr<EngineInterface> engine_;
std::unique_ptr<SessionHandlerInterface> handler_;
std::unique_ptr<const UserPOSInterface> user_pos_;
#ifdef GOOGLE_JAPANESE_INPUT_BUILD
scoped_ptr<SessionUsageObserver> usage_observer_;
scoped_ptr<chrome::nacl::DictionaryDownloader> downloader_;
std::unique_ptr<SessionUsageObserver> usage_observer_;
std::unique_ptr<chrome::nacl::DictionaryDownloader> downloader_;
string big_dictionary_version_;
#endif // GOOGLE_JAPANESE_INPUT_BUILD
DISALLOW_COPY_AND_ASSIGN(MozcSessionHandlerThread);
Expand All @@ -425,7 +426,7 @@ class NaclSessionHandlerInstance : public pp::Instance {
private:
void CheckStatusAndStartMozcSessionHandlerThread();

scoped_ptr<MozcSessionHandlerThread> mozc_thread_;
std::unique_ptr<MozcSessionHandlerThread> mozc_thread_;
BlockingQueue<Json::Value *> message_queue_;

DISALLOW_COPY_AND_ASSIGN(NaclSessionHandlerInstance);
Expand All @@ -442,7 +443,7 @@ void NaclSessionHandlerInstance::HandleMessage(const pp::Var &var_message) {
return;
}

scoped_ptr<Json::Value> message(new Json::Value);
std::unique_ptr<Json::Value> message(new Json::Value);
if (Json::Reader().parse(var_message.AsString(), *message.get())) {
message_queue_.put(message.release());
}
Expand Down
1 change: 0 additions & 1 deletion src/chrome/nacl/url_loader_util.cc
Expand Up @@ -44,7 +44,6 @@

#include "base/logging.h"
#include "base/port.h"
#include "base/scoped_ptr.h"

using std::unique_ptr;

Expand Down
5 changes: 3 additions & 2 deletions src/client/client.cc
Expand Up @@ -39,6 +39,7 @@
#endif // OS_WIN

#include <cstddef>
#include <memory>

#include "base/const.h"
#include "base/file_stream.h"
Expand Down Expand Up @@ -553,7 +554,7 @@ bool Client::PingServer() const {
input.set_type(commands::Input::NO_OPERATION);

// Call IPC
scoped_ptr<IPCClientInterface> client(
std::unique_ptr<IPCClientInterface> client(
client_factory_->NewClient(kServerAddress,
server_launcher_->server_program()));

Expand Down Expand Up @@ -624,7 +625,7 @@ bool Client::Call(const commands::Input &input,
input.SerializeToString(&request);

// Call IPC
scoped_ptr<IPCClientInterface> client(
std::unique_ptr<IPCClientInterface> client(
client_factory_->NewClient(kServerAddress,
server_launcher_->server_program()));

Expand Down
9 changes: 5 additions & 4 deletions src/client/client.h
Expand Up @@ -32,10 +32,11 @@
#ifndef MOZC_CLIENT_CLIENT_H_
#define MOZC_CLIENT_CLIENT_H_

#include <memory>
#include <string>
#include <vector>

#include "base/port.h"
#include "base/scoped_ptr.h"
#include "client/client_interface.h"
#include "protocol/commands.pb.h"
#include "testing/base/public/gunit_prod.h"
Expand Down Expand Up @@ -242,9 +243,9 @@ class Client : public ClientInterface {

uint64 id_;
IPCClientFactoryInterface *client_factory_;
scoped_ptr<ServerLauncherInterface> server_launcher_;
scoped_ptr<char[]> result_;
scoped_ptr<config::Config> preferences_;
std::unique_ptr<ServerLauncherInterface> server_launcher_;
std::unique_ptr<char[]> result_;
std::unique_ptr<config::Config> preferences_;
int timeout_;
ServerStatus server_status_;
uint32 server_protocol_version_;
Expand Down
5 changes: 3 additions & 2 deletions src/client/client_scenario_test_main.cc
Expand Up @@ -32,6 +32,7 @@
// events specified by FLAGS_input file or interactive standard input. Input
// file format is same as one of session/session_client_main.

#include <memory>
#include <string>
#include <vector>

Expand Down Expand Up @@ -100,7 +101,7 @@ int Loop(istream *input) {
CHECK(client.EnsureSession()) << "EnsureSession failed";
CHECK(client.NoOperation()) << "Server is not responding";

scoped_ptr<mozc::renderer::RendererClient> renderer_client;
std::unique_ptr<mozc::renderer::RendererClient> renderer_client;
mozc::commands::RendererCommand renderer_command;

if (FLAGS_test_renderer) {
Expand Down Expand Up @@ -175,7 +176,7 @@ int main(int argc, char **argv) {
mozc::SystemUtil::SetUserProfileDirectory(FLAGS_profile_dir);
}

scoped_ptr<mozc::InputFileStream> input_file;
std::unique_ptr<mozc::InputFileStream> input_file;
istream *input = NULL;

if (!FLAGS_input.empty()) {
Expand Down
5 changes: 3 additions & 2 deletions src/client/client_stress_test_main.cc
Expand Up @@ -36,11 +36,12 @@
#include <unistd.h>
#endif // OS_WIN

#include <memory>

#include "base/file_stream.h"
#include "base/flags.h"
#include "base/logging.h"
#include "base/port.h"
#include "base/scoped_ptr.h"
#include "base/util.h"
#include "protocol/renderer_command.pb.h"
#include "renderer/renderer_client.h"
Expand Down Expand Up @@ -73,7 +74,7 @@ int main(int argc, char **argv) {
CHECK(client.EnsureSession()) << "EnsureSession failed";
CHECK(client.NoOperation()) << "Server is not respoinding";

scoped_ptr<mozc::renderer::RendererClient> renderer_client;
std::unique_ptr<mozc::renderer::RendererClient> renderer_client;
mozc::commands::RendererCommand renderer_command;

if (FLAGS_test_renderer) {
Expand Down
11 changes: 6 additions & 5 deletions src/client/client_test.cc
Expand Up @@ -30,6 +30,7 @@
#include "client/client.h"

#include <map>
#include <memory>
#include <string>

#include "base/logging.h"
Expand Down Expand Up @@ -220,8 +221,8 @@ class ClientTest : public testing::Test {
return client_->EnsureConnection();
}

scoped_ptr<IPCClientFactoryMock> client_factory_;
scoped_ptr<Client> client_;
std::unique_ptr<IPCClientFactoryMock> client_factory_;
std::unique_ptr<Client> client_;
TestServerLauncher *server_launcher_;
int version_diff_;

Expand Down Expand Up @@ -771,9 +772,9 @@ class SessionPlaybackTest : public testing::Test {
ipc_client_factory_->SetMockResponse(response);
}

scoped_ptr<IPCClientFactoryMock> ipc_client_factory_;
scoped_ptr<IPCClientMock> ipc_client_;
scoped_ptr<Client> client_;
std::unique_ptr<IPCClientFactoryMock> ipc_client_factory_;
std::unique_ptr<IPCClientMock> ipc_client_;
std::unique_ptr<Client> client_;
SessionPlaybackTestServerLauncher *server_launcher_;

private:
Expand Down
4 changes: 2 additions & 2 deletions src/composer/composer.h
Expand Up @@ -32,13 +32,13 @@
#ifndef MOZC_COMPOSER_COMPOSER_H_
#define MOZC_COMPOSER_COMPOSER_H_

#include <memory>
#include <set>
#include <string>
#include <vector>

#include "base/port.h"
#include "base/protobuf/repeated_field.h"
#include "base/scoped_ptr.h"
#include "composer/internal/typing_corrector.h"
#include "composer/internal/transliterators.h"
#include "composer/type_corrected_query.h"
Expand Down Expand Up @@ -260,7 +260,7 @@ class Composer {
commands::Context::InputFieldType input_field_type_;

size_t shifted_sequence_count_;
scoped_ptr<CompositionInterface> composition_;
std::unique_ptr<CompositionInterface> composition_;

TypingCorrector typing_corrector_;

Expand Down
4 changes: 2 additions & 2 deletions src/composer/composer_main.cc
Expand Up @@ -30,10 +30,10 @@
#include "composer/composer.h"

#include <iostream> // NOLINT
#include <memory>
#include <string>

#include "base/flags.h"
#include "base/scoped_ptr.h"
#include "composer/composition_interface.h"
#include "composer/table.h"
#include "protocol/commands.pb.h"
Expand All @@ -49,7 +49,7 @@ int main(int argc, char **argv) {

mozc::composer::Table table;
table.LoadFromFile(FLAGS_table.c_str());
scoped_ptr<mozc::composer::Composer> composer(
std::unique_ptr<mozc::composer::Composer> composer(
new mozc::composer::Composer(&table, &Request::default_instance()));

string command;
Expand Down
13 changes: 7 additions & 6 deletions src/composer/composer_test.cc
Expand Up @@ -29,6 +29,7 @@

#include "composer/composer.h"

#include <memory>
#include <string>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -148,9 +149,9 @@ class ComposerTest : public testing::Test {
ConfigHandler::SetConfig(config);
}

scoped_ptr<Composer> composer_;
scoped_ptr<Table> table_;
scoped_ptr<Request> default_request_;
std::unique_ptr<Composer> composer_;
std::unique_ptr<Table> table_;
std::unique_ptr<Request> default_request_;

private:
DISALLOW_COPY_AND_ASSIGN(ComposerTest);
Expand Down Expand Up @@ -3341,9 +3342,9 @@ class TypingCorrectionTest : public ::testing::Test {
return queries.empty();
}

scoped_ptr<Request> request_;
scoped_ptr<Composer> composer_;
scoped_ptr<Table> table_;
std::unique_ptr<Request> request_;
std::unique_ptr<Composer> composer_;
std::unique_ptr<Table> table_;
Config config_backup_;
};

Expand Down

0 comments on commit 1ed3119

Please sign in to comment.