Commit 7cbf7ae2 authored by davemoore's avatar davemoore Committed by Commit bot

Make ApplicationImpl::args() be a std::vector<std::string>

BUG=

Review URL: https://codereview.chromium.org/657393003

Cr-Commit-Position: refs/heads/master@{#300033}
parent 523714fe
...@@ -108,9 +108,7 @@ class TestApplicationLoader : public ApplicationLoader, ...@@ -108,9 +108,7 @@ class TestApplicationLoader : public ApplicationLoader,
void set_context(TestContext* context) { context_ = context; } void set_context(TestContext* context) { context_ = context; }
int num_loads() const { return num_loads_; } int num_loads() const { return num_loads_; }
std::vector<std::string> GetArgs() { const std::vector<std::string>& GetArgs() { return test_app_->args(); }
return test_app_->args().To<std::vector<std::string> >();
}
private: private:
// ApplicationLoader implementation. // ApplicationLoader implementation.
......
...@@ -97,7 +97,7 @@ MojoResult MojoMain(MojoHandle shell_handle) { ...@@ -97,7 +97,7 @@ MojoResult MojoMain(MojoHandle shell_handle) {
{ {
// InitGoogleTest expects (argc + 1) elements, including a terminating NULL. // InitGoogleTest expects (argc + 1) elements, including a terminating NULL.
// It also removes GTEST arguments from |argv| and updates the |argc| count. // It also removes GTEST arguments from |argv| and updates the |argc| count.
const mojo::Array<mojo::String>& args = app.args(); const std::vector<std::string>& args = app.args();
MOJO_CHECK(args.size() < INT_MAX); MOJO_CHECK(args.size() < INT_MAX);
int argc = static_cast<int>(args.size()); int argc = static_cast<int>(args.size());
std::vector<char*> argv(argc + 1); std::vector<char*> argv(argc + 1);
......
...@@ -76,8 +76,8 @@ class WGetApp : public ApplicationDelegate { ...@@ -76,8 +76,8 @@ class WGetApp : public ApplicationDelegate {
} }
private: private:
void Start(const Array<String>& args) { void Start(const std::vector<std::string>& args) {
std::string url((args.size() > 1) ? args[1].get() : PromptForURL()); std::string url((args.size() > 1) ? args[1] : PromptForURL());
printf("Loading: %s\n", url.c_str()); printf("Loading: %s\n", url.c_str());
network_service_->CreateURLLoader(GetProxy(&url_loader_)); network_service_->CreateURLLoader(GetProxy(&url_loader_));
......
...@@ -60,7 +60,7 @@ class ApplicationImpl : public InterfaceImpl<Application> { ...@@ -60,7 +60,7 @@ class ApplicationImpl : public InterfaceImpl<Application> {
Shell* shell() const { return shell_.get(); } Shell* shell() const { return shell_.get(); }
// Returns any initial configuration arguments, passed by the Shell. // Returns any initial configuration arguments, passed by the Shell.
const Array<String>& args() { return args_; } const std::vector<std::string>& args() { return args_; }
// Establishes a new connection to an application. Caller does not own. // Establishes a new connection to an application. Caller does not own.
ApplicationConnection* ConnectToApplication(const String& application_url); ApplicationConnection* ConnectToApplication(const String& application_url);
...@@ -102,7 +102,7 @@ class ApplicationImpl : public InterfaceImpl<Application> { ...@@ -102,7 +102,7 @@ class ApplicationImpl : public InterfaceImpl<Application> {
ApplicationDelegate* delegate_; ApplicationDelegate* delegate_;
ShellPtr shell_; ShellPtr shell_;
ShellPtrWatcher* shell_watch_; ShellPtrWatcher* shell_watch_;
Array<String> args_; std::vector<std::string> args_;
MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl);
}; };
......
...@@ -57,7 +57,7 @@ ApplicationImpl::~ApplicationImpl() { ...@@ -57,7 +57,7 @@ ApplicationImpl::~ApplicationImpl() {
void ApplicationImpl::Initialize(Array<String> args) { void ApplicationImpl::Initialize(Array<String> args) {
MOJO_CHECK(!initialized_); MOJO_CHECK(!initialized_);
initialized_ = true; initialized_ = true;
args_ = args.Pass(); args_ = args.To<std::vector<std::string>>();
delegate_->Initialize(this); delegate_->Initialize(this);
} }
......
...@@ -32,13 +32,13 @@ class NativeViewportAppDelegate ...@@ -32,13 +32,13 @@ class NativeViewportAppDelegate
private: private:
bool HasArg(const std::string& arg) { bool HasArg(const std::string& arg) {
return std::find(args_.begin(), args_.end(), arg) != args_.end(); const auto& args = app_->args();
return std::find(args.begin(), args.end(), arg) != args.end();
} }
// ApplicationDelegate implementation. // ApplicationDelegate implementation.
virtual void Initialize(ApplicationImpl* application) override { virtual void Initialize(ApplicationImpl* application) override {
app_ = application; app_ = application;
args_ = application->args().To<std::vector<std::string> >();
#if !defined(COMPONENT_BUILD) #if !defined(COMPONENT_BUILD)
if (HasArg(kUseTestConfig)) if (HasArg(kUseTestConfig))
...@@ -70,7 +70,6 @@ class NativeViewportAppDelegate ...@@ -70,7 +70,6 @@ class NativeViewportAppDelegate
} }
ApplicationImpl* app_; ApplicationImpl* app_;
std::vector<std::string> args_;
scoped_refptr<gfx::GLShareGroup> share_group_; scoped_refptr<gfx::GLShareGroup> share_group_;
scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
bool is_headless_; bool is_headless_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment