This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tizen] Refactor XWalkLauncher for usage of RESET event.
After this change execute xwalk-launcher on Tizen will cause initialization of app core and launch of g_main_loop. Application will be actually launched after xwalk-launcher receives RESET event from platform. BUG=XWALK-2779
- Loading branch information
1 parent
50e7278
commit 8b67e6b
Showing
11 changed files
with
588 additions
and
360 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// Copyright (c) 2013 Intel Corporation. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "xwalk/application/tools/linux/dbus_object_manager.h" | ||
|
||
#include "base/message_loop/message_loop.h" | ||
|
||
namespace { | ||
|
||
const char kServiceName[] = "org.crosswalkproject.Runtime1"; | ||
const char kRunningManagerIface[] = "org.crosswalkproject.Running.Manager1"; | ||
const char kRunningAppIface[] = "org.crosswalkproject.Running.Application1"; | ||
const dbus::ObjectPath kRunningManagerDBusPath("/running1"); | ||
|
||
} // namespace | ||
|
||
DBusObjectManager::DBusObjectManager(dbus::Bus* bus, | ||
base::MessageLoop* main_loop) | ||
: bus_(bus), | ||
main_loop_(main_loop) { | ||
ConnectToApplicationManager(); | ||
} | ||
|
||
void DBusObjectManager::DBusCallLaunchMethod( | ||
const std::string& appid_or_url, int launcher_pid, bool fullscreen, | ||
bool remote_debugging) { | ||
dbus::MethodCall method_call( | ||
kRunningManagerIface, "Launch"); | ||
dbus::MessageWriter writer(&method_call); | ||
writer.AppendString(appid_or_url); | ||
writer.AppendUint32(launcher_pid); | ||
writer.AppendBool(fullscreen); | ||
writer.AppendBool(remote_debugging); | ||
scoped_ptr<dbus::Response> response( | ||
running_proxy_->CallMethodAndBlock(&method_call, | ||
dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); | ||
|
||
if (!response.get()) | ||
exit(1); | ||
|
||
dbus::MessageReader reader(response.get()); | ||
dbus::ObjectPath running_manager_path; | ||
if (!reader.PopObjectPath(&running_manager_path)) | ||
LOG(WARNING) << "Failed to create app proxy."; | ||
else | ||
app_proxy_ = bus_->GetObjectProxy(std::string(kServiceName), | ||
running_manager_path); | ||
} | ||
|
||
scoped_ptr<dbus::Response> DBusObjectManager::CallGetEPChannelMethod() { | ||
dbus::MethodCall method_call(kRunningAppIface, "GetEPChannel"); | ||
return app_proxy_->CallMethodAndBlock( | ||
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT); | ||
} | ||
|
||
scoped_ptr<dbus::Response> DBusObjectManager::DBusCallSuspendMethod() { | ||
dbus::MethodCall method_call(kRunningAppIface, "Suspend"); | ||
return app_proxy_->CallMethodAndBlock( | ||
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT); | ||
} | ||
|
||
scoped_ptr<dbus::Response> DBusObjectManager::DBusCallResumeMethod() { | ||
dbus::MethodCall method_call(kRunningAppIface, "Resume"); | ||
return app_proxy_->CallMethodAndBlock( | ||
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT); | ||
} | ||
|
||
void DBusObjectManager::OnOwnershipCallback(const std::string& service_name, | ||
bool success) { | ||
LOG(WARNING) << "Couldn't get ownership of D-Bus service name: " | ||
<< service_name << "."; | ||
} | ||
|
||
void DBusObjectManager::ConnectToApplicationManager() { | ||
bus_->RequestOwnershipAndBlock(kServiceName, | ||
dbus::Bus::REQUIRE_PRIMARY); | ||
running_apps_manager_ = bus_->GetObjectManager(kServiceName, | ||
kRunningManagerDBusPath); | ||
running_apps_manager_->RegisterInterface(kRunningAppIface, this); | ||
running_proxy_ = bus_->GetObjectProxy(kServiceName, kRunningManagerDBusPath); | ||
} | ||
|
||
void DBusObjectManager::ObjectAdded(const dbus::ObjectPath& object_path, | ||
const std::string& interface_name) { | ||
} | ||
|
||
void DBusObjectManager::ObjectRemoved(const dbus::ObjectPath& object_path, | ||
const std::string& interface_name) { | ||
if (object_path != app_proxy_->object_path()) | ||
return; | ||
LOG(INFO) << "Application '" << object_path.value().c_str() | ||
<< "' disappeared, exiting."; | ||
main_loop_->QuitNow(); | ||
} | ||
|
||
dbus::PropertySet* DBusObjectManager::CreateProperties( | ||
dbus::ObjectProxy *object_proxy, | ||
const dbus::ObjectPath& object_path, | ||
const std::string& interface_name) { | ||
Properties* properties = new Properties( | ||
object_proxy, interface_name, | ||
base::Bind(&DBusObjectManager::OnPropertyChanged, | ||
base::Unretained(this), object_path)); | ||
return static_cast<dbus::PropertySet*>(properties); | ||
} | ||
|
||
void DBusObjectManager::OnPropertyChanged(const dbus::ObjectPath& object_path, | ||
const std::string& name) { | ||
if (!running_apps_manager_) | ||
ConnectToApplicationManager(); | ||
} | ||
|
||
dbus::ObjectProxy& DBusObjectManager::GetAppProxy() { | ||
return *app_proxy_; | ||
} | ||
|
||
scoped_refptr<dbus::ObjectManager> DBusObjectManager::GetRunningAppsManager() { | ||
if (!running_apps_manager_) | ||
ConnectToApplicationManager(); | ||
return running_apps_manager_; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (c) 2013 Intel Corporation. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef XWALK_APPLICATION_TOOLS_LINUX_DBUS_OBJECT_MANAGER_H_ | ||
#define XWALK_APPLICATION_TOOLS_LINUX_DBUS_OBJECT_MANAGER_H_ | ||
|
||
#include <string> | ||
#include <map> | ||
|
||
#include "base/macros.h" | ||
#include "base/threading/thread.h" | ||
#include "base/values.h" | ||
#include "dbus/bus.h" | ||
#include "dbus/exported_object.h" | ||
#include "dbus/message.h" | ||
#include "dbus/object_manager.h" | ||
#include "dbus/object_path.h" | ||
#include "dbus/object_proxy.h" | ||
#include "dbus/property.h" | ||
|
||
class DBusObjectManager : public dbus::ObjectManager::Interface { | ||
public: | ||
DBusObjectManager(dbus::Bus* bus, base::MessageLoop* main_loop); | ||
|
||
void DBusCallLaunchMethod(const std::string& appid_or_url, int launcher_pid, | ||
bool fullscreen, bool remote_debugging); | ||
scoped_ptr<dbus::Response> CallGetEPChannelMethod(); | ||
scoped_ptr<dbus::Response> DBusCallSuspendMethod(); | ||
scoped_ptr<dbus::Response> DBusCallResumeMethod(); | ||
|
||
dbus::ObjectProxy& GetAppProxy(); | ||
scoped_refptr<dbus::ObjectManager> GetRunningAppsManager(); | ||
|
||
struct Properties : public dbus::PropertySet { | ||
dbus::Property<std::string> app_id; | ||
|
||
Properties(dbus::ObjectProxy* object_proxy, | ||
const std::string& interface_name, | ||
PropertyChangedCallback property_changed_callback) | ||
: PropertySet(object_proxy, interface_name, property_changed_callback) { | ||
RegisterProperty("AppID", &app_id); | ||
} | ||
}; | ||
|
||
private: | ||
void OnOwnershipCallback(const std::string& service_name, bool success); | ||
void ObjectAdded(const dbus::ObjectPath& object_path, | ||
const std::string& interface_name) override; | ||
void ObjectRemoved(const dbus::ObjectPath& object_path, | ||
const std::string& interface_name) override; | ||
dbus::PropertySet* CreateProperties( | ||
dbus::ObjectProxy* object_proxy, | ||
const dbus::ObjectPath& object_path, | ||
const std::string& interface_name) override; | ||
|
||
void OnPropertyChanged(const dbus::ObjectPath& object_path, | ||
const std::string& name); | ||
|
||
void ConnectToApplicationManager(); | ||
|
||
scoped_refptr<dbus::Bus> bus_; | ||
dbus::ObjectManager* running_apps_manager_; | ||
dbus::ObjectProxy* running_proxy_; | ||
dbus::ObjectProxy* app_proxy_; | ||
|
||
// this is needed for exit events which come via dbus interface | ||
base::MessageLoop* main_loop_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(DBusObjectManager); | ||
}; | ||
|
||
#endif // XWALK_APPLICATION_TOOLS_LINUX_DBUS_OBJECT_MANAGER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.