summaryrefslogtreecommitdiffstats
path: root/chrome/common/appcache/chrome_appcache_service.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common/appcache/chrome_appcache_service.cc')
-rw-r--r--chrome/common/appcache/chrome_appcache_service.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/common/appcache/chrome_appcache_service.cc b/chrome/common/appcache/chrome_appcache_service.cc
new file mode 100644
index 0000000..c1016cb
--- /dev/null
+++ b/chrome/common/appcache/chrome_appcache_service.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/appcache/chrome_appcache_service.h"
+
+#include "base/file_path.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/common/chrome_constants.h"
+#include "webkit/appcache/appcache_thread.h"
+
+static bool has_initialized_thread_ids;
+
+ChromeAppCacheService::ChromeAppCacheService(const FilePath& data_directory,
+ bool is_incognito) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ if (!has_initialized_thread_ids) {
+ has_initialized_thread_ids = true;
+ appcache::AppCacheThread::InitIDs(ChromeThread::DB, ChromeThread::IO);
+ }
+ Initialize(is_incognito ? FilePath()
+ : data_directory.Append(chrome::kAppCacheDirname));
+}
+
+ChromeAppCacheService::~ChromeAppCacheService() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+}
+
+static ChromeThread::ID ToChromeThreadID(int id) {
+ DCHECK(has_initialized_thread_ids);
+ DCHECK(id == ChromeThread::DB || id == ChromeThread::IO);
+ return static_cast<ChromeThread::ID>(id);
+}
+
+namespace appcache {
+
+// An impl of AppCacheThread we need to provide to the appcache lib.
+
+bool AppCacheThread::PostTask(
+ int id,
+ const tracked_objects::Location& from_here,
+ Task* task) {
+ return ChromeThread::PostTask(ToChromeThreadID(id), from_here, task);
+}
+
+bool AppCacheThread::CurrentlyOn(int id) {
+ return ChromeThread::CurrentlyOn(ToChromeThreadID(id));
+}
+
+} // namespace appcache