| 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..0e03816f53f7b35f9ef0901960cefaeea35969f0
|
| --- /dev/null
|
| +++ b/content/public/common/static_mojo_application_loader.h
|
| @@ -0,0 +1,69 @@
|
| +// 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 "base/callback.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "content/common/content_export.h"
|
| +#include "mojo/shell/application_loader.h"
|
| +
|
| +namespace base {
|
| +class Thread;
|
| +}
|
| +
|
| +namespace mojo {
|
| +class ApplicationDelegate;
|
| +}
|
| +
|
| +namespace content {
|
| +
|
| +class CONTENT_EXPORT StaticMojoApplicationLoader
|
| + : public mojo::shell::ApplicationLoader {
|
| + public:
|
| + using ApplicationFactory =
|
| + base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>;
|
| +
|
| + // Constructs a static loader for |factory|.
|
| + explicit StaticMojoApplicationLoader(const ApplicationFactory& factory);
|
| +
|
| + // Constructs a static loader for |factory| with a closure that will be called
|
| + // when the loaded application quits.
|
| + StaticMojoApplicationLoader(const ApplicationFactory& factory,
|
| + const base::Closure& quit_callback);
|
| +
|
| + ~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 CleanUpAppThread(typename ThreadList::iterator iter);
|
| +
|
| + // The factory used t create new instances of the application delegate.
|
| + ApplicationFactory factory_;
|
| +
|
| + // If not null, this is called when an instance of the loaded application
|
| + // quits.
|
| + base::Closure quit_callback_;
|
| +
|
| + // 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_
|
|
|