Restore variadic macros in DevToolsEmbedderMessageDispatcher
[chromium-blink-merge.git] / mojo / shell / application_instance.h
blob06e611e3ff4007465bf03820920bbbaf14da3441
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MOJO_SHELL_APPLICATION_INSTANCE_H_
6 #define MOJO_SHELL_APPLICATION_INSTANCE_H_
8 #include <set>
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "mojo/application/public/interfaces/application.mojom.h"
13 #include "mojo/application/public/interfaces/shell.mojom.h"
14 #include "mojo/public/cpp/bindings/binding.h"
15 #include "mojo/shell/capability_filter.h"
16 #include "mojo/shell/connect_to_application_params.h"
17 #include "mojo/shell/identity.h"
18 #include "url/gurl.h"
20 namespace mojo {
21 namespace shell {
23 class ApplicationManager;
25 // Encapsulates a connection to an instance of an application, tracked by the
26 // shell's ApplicationManager.
27 class ApplicationInstance : public Shell {
28 public:
29 // |requesting_content_handler_id| is the id of the content handler that
30 // loaded this app. If the app was not loaded by a content handler the id
31 // is kInvalidContentHandlerID.
32 ApplicationInstance(ApplicationPtr application,
33 ApplicationManager* manager,
34 const Identity& originator_identity,
35 const Identity& resolved_identity,
36 const CapabilityFilter& filter,
37 uint32_t requesting_content_handler_id,
38 const base::Closure& on_application_end);
40 ~ApplicationInstance() override;
42 void InitializeApplication();
44 void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params);
46 Application* application() { return application_.get(); }
47 const Identity& identity() const { return identity_; }
48 const CapabilityFilter& filter() const { return filter_; }
49 base::Closure on_application_end() const { return on_application_end_; }
50 void set_requesting_content_handler_id(uint32_t id) {
51 requesting_content_handler_id_ = id;
53 uint32_t requesting_content_handler_id() const {
54 return requesting_content_handler_id_;
57 private:
58 // Shell implementation:
59 void ConnectToApplication(
60 URLRequestPtr app_request,
61 InterfaceRequest<ServiceProvider> services,
62 ServiceProviderPtr exposed_services,
63 CapabilityFilterPtr filter,
64 const ConnectToApplicationCallback& callback) override;
65 void QuitApplication() override;
67 void CallAcceptConnection(scoped_ptr<ConnectToApplicationParams> params);
69 void OnConnectionError();
71 void OnQuitRequestedResult(bool can_quit);
73 ApplicationManager* const manager_;
74 const Identity originator_identity_;
75 const Identity identity_;
76 const CapabilityFilter filter_;
77 const bool allow_any_application_;
78 uint32_t requesting_content_handler_id_;
79 base::Closure on_application_end_;
80 ApplicationPtr application_;
81 Binding<Shell> binding_;
82 bool queue_requests_;
83 std::vector<ConnectToApplicationParams*> queued_client_requests_;
85 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance);
88 } // namespace shell
89 } // namespace mojo
91 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_