1 // Copyright (c) 2013 Intel Corporation. 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 XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATION_OBJECT_H_
6 #define XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATION_OBJECT_H_
9 #include "base/memory/ref_counted.h"
11 #include "ipc/ipc_channel_handle.h"
12 #include "xwalk/application/browser/application.h"
13 #include "xwalk/dbus/object_manager_adaptor.h"
20 namespace application {
22 // Represents the running application inside D-Bus hierarchy of
23 // RunningApplicationsManager.
25 // Watches for the D-Bus presence of the launcher, when it disappears (e.g. the
26 // launcher was ended by a task manager) will terminate the corresponding
27 // application in Crosswalk.
28 class RunningApplicationObject : public dbus::ManagedObject {
30 RunningApplicationObject(scoped_refptr<dbus::Bus> bus,
31 const std::string& app_id,
32 const std::string& launcher_name,
33 Application* application);
35 virtual ~RunningApplicationObject();
37 void ExtensionProcessCreated(const IPC::ChannelHandle& handle);
40 void TerminateApplication(Application::TerminationMode mode);
42 void OnExported(const std::string& interface_name,
43 const std::string& method_name,
46 void OnTerminate(Application::TerminationMode termination_mode,
47 dbus::MethodCall* method_call,
48 dbus::ExportedObject::ResponseSender response_sender);
50 void OnGetExtensionProcessChannel(
51 dbus::MethodCall* method_call,
52 dbus::ExportedObject::ResponseSender response_sender);
55 void OnHide(dbus::MethodCall* method_call,
56 dbus::ExportedObject::ResponseSender response_sender);
59 void ListenForOwnerChange();
60 void UnlistenForOwnerChange();
61 void OnNameOwnerChanged(const std::string& service_owner);
63 void OnLauncherDisappeared();
65 scoped_ptr<dbus::FileDescriptor> CreateClientFileDescriptor();
66 void SendChannel(dbus::MethodCall* method_call,
67 dbus::ExportedObject::ResponseSender response_sender,
68 scoped_ptr<dbus::FileDescriptor> client_fd);
70 scoped_refptr<dbus::Bus> bus_;
71 std::string launcher_name_;
72 dbus::Bus::GetServiceOwnerCallback owner_change_callback_;
73 Application* application_;
75 IPC::ChannelHandle ep_bp_channel_;
78 } // namespace application
81 #endif // XWALK_APPLICATION_BROWSER_LINUX_RUNNING_APPLICATION_OBJECT_H_