mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
The tracing service logically provides one service, TraceCoordinator, which can start and stop tracing sessions. It also can connect to any number of TraceControllers each of which can supply tracing information on demand. Whenever an app connects to the tracing service, the tracing service attempts to connect to that app's TraceController interface. If the app provides this interface then tracing data will be requested whenever tracing starts. If the app doesn't, then the pipe just closes. Thus apps that want to be traced can do so by creating however many connections to the tracing service they want and registering a TraceController implementation on each outgoing connection. The shell connects in a similar fashion by connecting to the tracing service and providing a TraceController implementation. The code looks a bit different since the shell is special. BUG=451319 R=viettrungluu@chromium.org Review URL: https://codereview.chromium.org/791493006
68 lines
2.2 KiB
C++
68 lines
2.2 KiB
C++
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "base/files/file_path.h"
|
|
#include "base/message_loop/message_loop.h"
|
|
#include "base/threading/thread.h"
|
|
#include "mojo/application/application_runner_chromium.h"
|
|
#include "mojo/common/tracing_impl.h"
|
|
#include "mojo/icu/icu.h"
|
|
#include "mojo/public/c/system/main.h"
|
|
#include "mojo/public/cpp/application/application_connection.h"
|
|
#include "mojo/public/cpp/application/application_delegate.h"
|
|
#include "mojo/public/cpp/application/application_impl.h"
|
|
#include "mojo/public/cpp/application/interface_factory_impl.h"
|
|
#include "mojo/services/content_handler/public/interfaces/content_handler.mojom.h"
|
|
#include "sky/engine/public/web/Sky.h"
|
|
#include "sky/viewer/content_handler_impl.h"
|
|
#include "sky/viewer/document_view.h"
|
|
#include "sky/viewer/platform/platform_impl.h"
|
|
#include "sky/viewer/runtime_flags.h"
|
|
|
|
namespace sky {
|
|
|
|
class Viewer : public mojo::ApplicationDelegate,
|
|
public mojo::InterfaceFactory<mojo::ContentHandler> {
|
|
public:
|
|
Viewer() {}
|
|
|
|
virtual ~Viewer() { blink::shutdown(); }
|
|
|
|
private:
|
|
// Overridden from ApplicationDelegate:
|
|
virtual void Initialize(mojo::ApplicationImpl* app) override {
|
|
RuntimeFlags::Initialize(app);
|
|
|
|
platform_impl_.reset(new PlatformImpl(app));
|
|
blink::initialize(platform_impl_.get());
|
|
|
|
mojo::icu::Initialize(app);
|
|
tracing_.Initialize(app);
|
|
}
|
|
|
|
virtual bool ConfigureIncomingConnection(
|
|
mojo::ApplicationConnection* connection) override {
|
|
connection->AddService<mojo::ContentHandler>(this);
|
|
return true;
|
|
}
|
|
|
|
// Overridden from InterfaceFactory<ContentHandler>
|
|
virtual void Create(mojo::ApplicationConnection* connection,
|
|
mojo::InterfaceRequest<mojo::ContentHandler> request) override {
|
|
mojo::BindToRequest(new ContentHandlerImpl(), &request);
|
|
}
|
|
|
|
scoped_ptr<PlatformImpl> platform_impl_;
|
|
mojo::TracingImpl tracing_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Viewer);
|
|
};
|
|
|
|
} // namespace sky
|
|
|
|
MojoResult MojoMain(MojoHandle shell_handle) {
|
|
mojo::ApplicationRunnerChromium runner(new sky::Viewer);
|
|
return runner.Run(shell_handle);
|
|
}
|