// 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_BROWSER_APPLICATION_SYSTEM_LINUX_H_
#define XWALK_APPLICATION_BROWSER_APPLICATION_SYSTEM_LINUX_H_

#include "xwalk/application/browser/application_system.h"

namespace xwalk {
class DBusManager;
}

namespace xwalk {
namespace application {

class ApplicationServiceProviderLinux;

class ApplicationSystemLinux : public ApplicationSystem {
 public:
  explicit ApplicationSystemLinux(RuntimeContext* runtime_context);
  virtual ~ApplicationSystemLinux();

  DBusManager& dbus_manager();

 private:
  scoped_ptr<DBusManager> dbus_manager_;
  scoped_ptr<ApplicationServiceProviderLinux> service_provider_;

  DISALLOW_COPY_AND_ASSIGN(ApplicationSystemLinux);
};

}  // namespace application
}  // namespace xwalk

#endif  // XWALK_APPLICATION_BROWSER_APPLICATION_SYSTEM_LINUX_H_

// 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_BROWSER_APPLICATION_SYSTEM_LINUX_H_
#define XWALK_APPLICATION_BROWSER_APPLICATION_SYSTEM_LINUX_H_

#include "xwalk/application/browser/application_system.h"

namespace xwalk {
class DBusManager;
}

namespace xwalk {
namespace application {

class ApplicationServiceProviderLinux;

class ApplicationSystemLinux : public ApplicationSystem {
 public:
  explicit ApplicationSystemLinux(RuntimeContext* runtime_context);
  virtual ~ApplicationSystemLinux();

  DBusManager& dbus_manager();

 private:
  scoped_ptr<ApplicationServiceProviderLinux> service_provider_;
  scoped_ptr<DBusManager> dbus_manager_;

  DISALLOW_COPY_AND_ASSIGN(ApplicationSystemLinux);
};

}  // namespace application
}  // namespace xwalk

#endif  // XWALK_APPLICATION_BROWSER_APPLICATION_SYSTEM_LINUX_H_

--- 
+++ 
@@ -24,8 +24,8 @@
   DBusManager& dbus_manager();
 
  private:
+  scoped_ptr<DBusManager> dbus_manager_;
   scoped_ptr<ApplicationServiceProviderLinux> service_provider_;
-  scoped_ptr<DBusManager> dbus_manager_;
 
   DISALLOW_COPY_AND_ASSIGN(ApplicationSystemLinux);
 };
[Application][D-Bus] Fix crash when shutting down

DBusManager owns the Bus connection and was being destroyed before the
service provider that uses it.

TEST=Loaded xwalk --run-as-service and xwalkctl <APP_ID> then closed the
window. The first process should not crash but exit cleanly.
