| Index: content/public/common/static_mojo_application_loader.h
|
| diff --git a/content/public/common/static_mojo_application_loader.h b/content/public/common/static_mojo_application_loader.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e312ac5a14f2b4b2afeb880751bbb5a539f9d52a
|
| --- /dev/null
|
| +++ b/content/public/common/static_mojo_application_loader.h
|
| @@ -0,0 +1,66 @@
|
| +// Copyright 2015 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.
|
| +
|
| +#ifndef CONTENT_PUBLIC_COMMON_STATIC_MOJO_APPLICATION_LOADER_H_
|
| +#define CONTENT_PUBLIC_COMMON_STATIC_MOJO_APPLICATION_LOADER_H_
|
| +
|
| +#include <list>
|
| +#include <string>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "mojo/shell/application_loader.h"
|
| +
|
| +namespace base {
|
| +class Thread;
|
| +}
|
| +
|
| +namespace mojo {
|
| +class ApplicationDelegate;
|
| +}
|
| +
|
| +namespace content {
|
| +
|
| +// This ApplicationLoader may be used to load applications which are linked into
|
| +// the content embedder's binary.
|
| +class StaticMojoApplicationLoader : public mojo::shell::ApplicationLoader {
|
| + public:
|
| + using ApplicationFactory =
|
| + base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>;
|
| +
|
| + // Create a new loader for a static applications. |name| is used to identify
|
| + // application-main threads. |factory| MUST be safe to run on any thread.
|
| + StaticMojoApplicationLoader(const std::string& name,
|
| + const ApplicationFactory& factory);
|
| + ~StaticMojoApplicationLoader() override;
|
| +
|
| + // mojo::shell::ApplicationLoader:
|
| + void Load(const GURL& url,
|
| + mojo::InterfaceRequest<mojo::Application> request) override;
|
| +
|
| + private:
|
| + using ThreadList = std::list<scoped_ptr<base::Thread>>;
|
| +
|
| + void ClearThread(typename ThreadList::iterator iter);
|
| +
|
| + // The name to use this app's threads.
|
| + std::string name_;
|
| +
|
| + // The factory used to create new instances of the application's delegate.
|
| + ApplicationFactory factory_;
|
| +
|
| + // List of all threads started by this loader. Each running instance of an
|
| + // application will have a corresponding thread in this list.
|
| + ThreadList threads_;
|
| +
|
| + base::WeakPtrFactory<StaticMojoApplicationLoader> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(StaticMojoApplicationLoader);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_PUBLIC_COMMON_STATIC_MOJO_APPLICATION_LOADER_H_
|
|
|