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

Unified Diff: examples/echo/echo_benchmark.cc

Issue 2015363003: Yet more ApplicationDelegate -> ApplicationImplBase conversion. (Closed) Base URL: https://github.com/domokit/mojo.git@work797-x-work796_no_run_main_app
Patch Set: rebased again Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/benchmark/benchmark_app.cc ('k') | examples/forwarding_content_handler/forwarding_content_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/echo/echo_benchmark.cc
diff --git a/examples/echo/echo_benchmark.cc b/examples/echo/echo_benchmark.cc
index 30e804488ebe26e5a74f463719b0cbb6045e245c..3d4f27dc60b0e2cb7590c5ebe8eee4def7ae141c 100644
--- a/examples/echo/echo_benchmark.cc
+++ b/examples/echo/echo_benchmark.cc
@@ -8,12 +8,12 @@
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "examples/echo/echo.mojom.h"
-#include "mojo/application/application_runner_chromium.h"
#include "mojo/common/tracing_impl.h"
+#include "mojo/environment/scoped_chromium_init.h"
#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/application/application_impl_base.h"
#include "mojo/public/cpp/application/connect.h"
+#include "mojo/public/cpp/application/run_application.h"
#include "mojo/public/cpp/utility/run_loop.h"
namespace mojo {
@@ -24,24 +24,24 @@ static const base::TimeDelta kWarmupTime =
static const base::TimeDelta kDelayTime = base::TimeDelta::FromMicroseconds(50);
-class EchoClientDelegate;
+class EchoClientApp;
class EchoResponse {
public:
- EchoResponse(EchoClientDelegate* echo, int idx, bool traced)
- : echoDelegate_(echo), idx_(idx), traced_(traced) {}
+ EchoResponse(EchoClientApp* echo, int idx, bool traced)
+ : echo_client_app_(echo), idx_(idx), traced_(traced) {}
void Run(const String& value) const;
private:
- EchoClientDelegate* echoDelegate_;
+ EchoClientApp* echo_client_app_;
int idx_;
bool traced_;
};
-class EchoClientDelegate : public ApplicationDelegate {
+class EchoClientApp : public ApplicationImplBase {
public:
- EchoClientDelegate()
+ EchoClientApp()
: warmup_(true),
num_clients_(1),
num_active_clients_(1),
@@ -49,25 +49,24 @@ class EchoClientDelegate : public ApplicationDelegate {
ending_(false),
benchmark_duration_(base::TimeDelta::FromSeconds(10)) {}
- void Initialize(ApplicationImpl* app) override {
- tracing_.Initialize(app->shell(), &app->args());
+ void OnInitialize() override {
+ tracing_.Initialize(shell(), &args());
- ParseArguments(app);
+ ParseArguments();
for (int i = 0; i < num_clients_; i++) {
EchoPtr echo;
if (use_dart_server_) {
- ConnectToService(app->shell(), "mojo:dart_echo_server",
- GetProxy(&echo));
+ ConnectToService(shell(), "mojo:dart_echo_server", GetProxy(&echo));
} else {
- ConnectToService(app->shell(), "mojo:echo_server", GetProxy(&echo));
+ ConnectToService(shell(), "mojo:echo_server", GetProxy(&echo));
}
echoClients_.push_back(echo.Pass());
}
BeginEcho(0);
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
- base::Bind(&EchoClientDelegate::EndWarmup, base::Unretained(this)),
+ base::Bind(&EchoClientApp::EndWarmup, base::Unretained(this)),
kWarmupTime);
}
@@ -77,12 +76,10 @@ class EchoClientDelegate : public ApplicationDelegate {
idx = 0;
}
base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&EchoClientDelegate::Run, base::Unretained(this), idx),
+ FROM_HERE, base::Bind(&EchoClientApp::Run, base::Unretained(this), idx),
kDelayTime);
base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&EchoClientDelegate::EndRun, base::Unretained(this)),
+ FROM_HERE, base::Bind(&EchoClientApp::EndRun, base::Unretained(this)),
benchmark_duration_);
}
@@ -129,10 +126,10 @@ class EchoClientDelegate : public ApplicationDelegate {
return false;
}
- void ParseArguments(ApplicationImpl* app) {
+ void ParseArguments() {
int benchmark_duration_seconds = 0;
- for (size_t i = 0; i < app->args().size(); i++) {
- const std::string& argument = app->args()[i];
+ for (size_t i = 0; i < args().size(); i++) {
+ const std::string& argument = args()[i];
if (GetBoolArgument(argument, "--dart-server", &use_dart_server_)) {
continue;
}
@@ -167,15 +164,15 @@ class EchoClientDelegate : public ApplicationDelegate {
};
void EchoResponse::Run(const String& value) const {
- echoDelegate_->EndEcho(idx_, traced_);
- echoDelegate_->BeginEcho(idx_ + 1);
+ echo_client_app_->EndEcho(idx_, traced_);
+ echo_client_app_->BeginEcho(idx_ + 1);
}
} // namespace examples
} // namespace mojo
MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(
- new mojo::examples::EchoClientDelegate);
- return runner.Run(application_request);
+ mojo::ScopedChromiumInit init;
+ mojo::examples::EchoClientApp echo_client_app;
+ return mojo::RunApplication(application_request, &echo_client_app);
}
« no previous file with comments | « apps/benchmark/benchmark_app.cc ('k') | examples/forwarding_content_handler/forwarding_content_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698