| Index: services/native_viewport/native_viewport_app.cc
 | 
| diff --git a/services/native_viewport/app_delegate.cc b/services/native_viewport/native_viewport_app.cc
 | 
| similarity index 60%
 | 
| rename from services/native_viewport/app_delegate.cc
 | 
| rename to services/native_viewport/native_viewport_app.cc
 | 
| index e0aeda1bcc45876bccc91126745340186f0a81ce..242ed4850d8632b1f30a498d37593a0dfaf1c24b 100644
 | 
| --- a/services/native_viewport/app_delegate.cc
 | 
| +++ b/services/native_viewport/native_viewport_app.cc
 | 
| @@ -2,71 +2,57 @@
 | 
|  // Use of this source code is governed by a BSD-style license that can be
 | 
|  // found in the LICENSE file.
 | 
|  
 | 
| -#include "services/native_viewport/app_delegate.h"
 | 
| +#include "services/native_viewport/native_viewport_app.h"
 | 
|  
 | 
|  #include <vector>
 | 
|  
 | 
|  #include "gpu/config/gpu_util.h"
 | 
| +#include "mojo/public/cpp/application/service_provider_impl.h"
 | 
| +#include "mojo/services/native_viewport/cpp/args.h"
 | 
| +#include "services/gles2/gpu_impl.h"
 | 
| +#include "services/native_viewport/native_viewport_impl.h"
 | 
| +#include "ui/events/event_switches.h"
 | 
| +#include "ui/gl/gl_surface.h"
 | 
|  
 | 
|  namespace native_viewport {
 | 
|  
 | 
| -NativeViewportAppDelegate::NativeViewportAppDelegate() : is_headless_(false) {}
 | 
| +NativeViewportApp::NativeViewportApp() : is_headless_(false) {}
 | 
|  
 | 
| -NativeViewportAppDelegate::~NativeViewportAppDelegate() {}
 | 
| +NativeViewportApp::~NativeViewportApp() {}
 | 
|  
 | 
| -void NativeViewportAppDelegate::InitLogging(
 | 
| -    mojo::ApplicationImpl* application) {
 | 
| -  std::vector<const char*> args;
 | 
| -  for (auto& a : application->args()) {
 | 
| -    args.push_back(a.c_str());
 | 
| -  }
 | 
| -
 | 
| -  base::CommandLine::Reset();
 | 
| -  base::CommandLine::Init(args.size(), args.data());
 | 
| -
 | 
| -  logging::LoggingSettings settings;
 | 
| -  settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
 | 
| -  logging::InitLogging(settings);
 | 
| -}
 | 
| -
 | 
| -void NativeViewportAppDelegate::Initialize(mojo::ApplicationImpl* application) {
 | 
| -  application_ = application;
 | 
| -
 | 
| -  InitLogging(application);
 | 
| -  tracing_.Initialize(application->shell(), &application->args());
 | 
| +void NativeViewportApp::OnInitialize() {
 | 
| +  InitLogging();
 | 
| +  tracing_.Initialize(shell(), &args());
 | 
|  
 | 
|    // Apply the switch for kTouchEvents to CommandLine (if set). This allows
 | 
|    // redirecting the mouse to a touch device on X for testing.
 | 
|    base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
 | 
|    const std::string touch_event_string("--" +
 | 
|                                         std::string(switches::kTouchDevices));
 | 
| -  auto touch_iter = std::find(application->args().begin(),
 | 
| -                              application->args().end(), touch_event_string);
 | 
| -  if (touch_iter != application->args().end() &&
 | 
| -      ++touch_iter != application->args().end()) {
 | 
| +  auto touch_iter = std::find(args().begin(), args().end(), touch_event_string);
 | 
| +  if (touch_iter != args().end() && ++touch_iter != args().end())
 | 
|      command_line->AppendSwitchASCII(touch_event_string, *touch_iter);
 | 
| -  }
 | 
|  
 | 
|    gpu::ApplyGpuDriverBugWorkarounds(command_line);
 | 
|  
 | 
| -  if (application->HasArg(mojo::kUseTestConfig))
 | 
| +  if (HasArg(mojo::kUseTestConfig))
 | 
|      gfx::GLSurface::InitializeOneOffForTests();
 | 
| -  else if (application->HasArg(mojo::kUseOSMesa))
 | 
| +  else if (HasArg(mojo::kUseOSMesa))
 | 
|      gfx::GLSurface::InitializeOneOff(gfx::kGLImplementationOSMesaGL);
 | 
|    else
 | 
|      gfx::GLSurface::InitializeOneOff();
 | 
|  
 | 
| -  is_headless_ = application->HasArg(mojo::kUseHeadlessConfig);
 | 
| +  is_headless_ = HasArg(mojo::kUseHeadlessConfig);
 | 
|  }
 | 
|  
 | 
| -bool NativeViewportAppDelegate::ConfigureIncomingConnection(
 | 
| +bool NativeViewportApp::OnAcceptConnection(
 | 
|      mojo::ServiceProviderImpl* service_provider_impl) {
 | 
|    service_provider_impl->AddService<mojo::NativeViewport>([this](
 | 
|        const mojo::ConnectionContext& connection_context,
 | 
|        mojo::InterfaceRequest<mojo::NativeViewport> native_viewport_request) {
 | 
|      if (!gpu_state_.get())
 | 
|        gpu_state_ = new gles2::GpuState();
 | 
| -    new NativeViewportImpl(application_->shell(), is_headless_, gpu_state_,
 | 
| +    new NativeViewportImpl(shell(), is_headless_, gpu_state_,
 | 
|                             native_viewport_request.Pass());
 | 
|    });
 | 
|  
 | 
| @@ -81,4 +67,17 @@ bool NativeViewportAppDelegate::ConfigureIncomingConnection(
 | 
|    return true;
 | 
|  }
 | 
|  
 | 
| +void NativeViewportApp::InitLogging() {
 | 
| +  std::vector<const char*> argv;
 | 
| +  for (const auto& a : args())
 | 
| +    argv.push_back(a.c_str());
 | 
| +
 | 
| +  base::CommandLine::Reset();
 | 
| +  base::CommandLine::Init(argv.size(), argv.data());
 | 
| +
 | 
| +  logging::LoggingSettings settings;
 | 
| +  settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
 | 
| +  logging::InitLogging(settings);
 | 
| +}
 | 
| +
 | 
|  }  // namespace native_viewport
 | 
| 
 |