summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/profile.cc1
-rwxr-xr-xchrome/chrome.gyp1
-rw-r--r--chrome/common/appcache/chrome_appcache_service.cc50
-rw-r--r--chrome/common/appcache/chrome_appcache_service.h22
4 files changed, 58 insertions, 16 deletions
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index f522360..a60b7fc 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_theme_provider.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/ntp_resource_cache.h"
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index f9bebb4..c80bc21 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -578,6 +578,7 @@
'common/appcache/appcache_dispatcher_host.h',
'common/appcache/appcache_frontend_proxy.cc',
'common/appcache/appcache_frontend_proxy.h',
+ 'common/appcache/chrome_appcache_service.cc',
'common/appcache/chrome_appcache_service.h',
'common/automation_constants.cc',
'common/automation_constants.h',
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
diff --git a/chrome/common/appcache/chrome_appcache_service.h b/chrome/common/appcache/chrome_appcache_service.h
index 37e0dcb..509afd2 100644
--- a/chrome/common/appcache/chrome_appcache_service.h
+++ b/chrome/common/appcache/chrome_appcache_service.h
@@ -5,38 +5,28 @@
#ifndef CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_
#define CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_
-#include "base/file_path.h"
-#include "base/message_loop.h"
#include "base/ref_counted.h"
-#include "base/task.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_thread.h"
-#include "chrome/common/chrome_constants.h"
#include "webkit/appcache/appcache_service.h"
+class FilePath;
+
// An AppCacheService subclass used by the chrome. There is an instance
// associated with each Profile. This derivation adds refcounting semantics
// since a profile has multiple URLRequestContexts which refer to the same
// object, and those URLRequestContexts are refcounted independently of the
// owning profile.
//
-// All methods, including the dtor, are expected to be called on the IO thread.
+// All methods, including the ctor and dtor, are expected to be called on
+// the IO thread.
class ChromeAppCacheService
: public base::RefCounted<ChromeAppCacheService>,
public appcache::AppCacheService {
public:
-
ChromeAppCacheService(const FilePath& data_directory,
- bool is_incognito) {
- Initialize(is_incognito ? FilePath()
- : data_directory.Append(chrome::kAppCacheDirname));
- }
+ bool is_incognito);
private:
friend class base::RefCounted<ChromeAppCacheService>;
-
- virtual ~ChromeAppCacheService() {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- }
+ virtual ~ChromeAppCacheService();
};
#endif // CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_