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_APPLICATION_STORAGE_IMPL_H_
6 #define XWALK_APPLICATION_BROWSER_APPLICATION_STORAGE_IMPL_H_
12 #include "base/files/file_path.h"
13 #include "sql/connection.h"
14 #include "sql/meta_table.h"
15 #include "xwalk/application/common/application_data.h"
18 namespace application {
20 // The Sqlite backend implementation of ApplicationStorage.
21 class ApplicationStorageImpl {
23 static const base::FilePath::CharType kDBFileName[];
24 explicit ApplicationStorageImpl(const base::FilePath& path);
25 ~ApplicationStorageImpl();
27 bool AddApplication(const ApplicationData* application,
28 const base::Time& install_time);
29 bool RemoveApplication(const std::string& key);
30 bool UpdateApplication(ApplicationData* application,
31 const base::Time& install_time);
32 bool Init(ApplicationData::ApplicationDataMap& applications);
33 bool GetInstalledApplications(
34 ApplicationData::ApplicationDataMap& applications);
37 bool UpgradeToVersion1(const base::FilePath& v0_file);
38 bool SetApplicationValue(const ApplicationData* application,
39 const base::Time& install_time,
40 const std::string& operation);
42 bool SetEventsValue(const std::string& id,
43 const std::set<std::string>& events,
44 const std::string& operation);
45 bool SetEvents(const std::string& id,
46 const std::set<std::string>& events);
47 bool UpdateEvents(const std::string& id,
48 const std::set<std::string>& events);
49 bool DeleteEvents(const std::string& id);
51 scoped_ptr<sql::Connection> sqlite_db_;
52 sql::MetaTable meta_table_;
53 base::FilePath data_path_;
57 } // namespace application
60 #endif // XWALK_APPLICATION_BROWSER_APPLICATION_STORAGE_IMPL_H_