summaryrefslogtreecommitdiffstats
path: root/chrome/common/appcache
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common/appcache')
-rw-r--r--chrome/common/appcache/appcache_dispatcher_host.cc13
-rw-r--r--chrome/common/appcache/appcache_dispatcher_host.h11
-rw-r--r--chrome/common/appcache/chrome_appcache_service.h43
3 files changed, 28 insertions, 39 deletions
diff --git a/chrome/common/appcache/appcache_dispatcher_host.cc b/chrome/common/appcache/appcache_dispatcher_host.cc
index 91a181f..d609858 100644
--- a/chrome/common/appcache/appcache_dispatcher_host.cc
+++ b/chrome/common/appcache/appcache_dispatcher_host.cc
@@ -5,12 +5,14 @@
#include "chrome/common/appcache/appcache_dispatcher_host.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
+// TODO(eroman): uh oh, depending on stuff outside of common/
+#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/common/appcache/chrome_appcache_service.h"
#include "chrome/common/render_messages.h"
AppCacheDispatcherHost::AppCacheDispatcherHost(
- ChromeAppCacheService* appcache_service)
- : appcache_service_(appcache_service),
+ URLRequestContextGetter* request_context_getter)
+ : request_context_getter_(request_context_getter),
process_handle_(0) {
}
@@ -19,6 +21,13 @@ void AppCacheDispatcherHost::Initialize(IPC::Message::Sender* sender,
DCHECK(sender);
DCHECK(process_handle && !process_handle_);
process_handle_ = process_handle;
+
+ // Get the AppCacheService (it can only be accessed from IO thread).
+ URLRequestContext* context = request_context_getter_->GetURLRequestContext();
+ appcache_service_ =
+ static_cast<ChromeURLRequestContext*>(context)->appcache_service();
+ request_context_getter_ = NULL;
+
frontend_proxy_.set_sender(sender);
if (appcache_service_.get()) {
backend_impl_.Initialize(
diff --git a/chrome/common/appcache/appcache_dispatcher_host.h b/chrome/common/appcache/appcache_dispatcher_host.h
index 31adcdf..7b04b9c 100644
--- a/chrome/common/appcache/appcache_dispatcher_host.h
+++ b/chrome/common/appcache/appcache_dispatcher_host.h
@@ -15,6 +15,7 @@
#include "webkit/appcache/appcache_backend_impl.h"
class ChromeAppCacheService;
+class URLRequestContextGetter;
// Handles appcache related messages sent to the main browser process from
// its child processes. There is a distinct host for each child process.
@@ -22,7 +23,8 @@ class ChromeAppCacheService;
// an instance and delegates calls to it.
class AppCacheDispatcherHost {
public:
- explicit AppCacheDispatcherHost(ChromeAppCacheService* appcache_service);
+ explicit AppCacheDispatcherHost(
+ URLRequestContextGetter* request_context_getter);
void Initialize(IPC::Message::Sender* sender, int process_id,
base::ProcessHandle process_handle);
@@ -56,7 +58,14 @@ class AppCacheDispatcherHost {
AppCacheFrontendProxy frontend_proxy_;
appcache::AppCacheBackendImpl backend_impl_;
+
+ // Temporary until Initialize() can be called from the IO thread,
+ // which will extract the AppCacheService from the URLRequestContext.
+ scoped_refptr<URLRequestContextGetter> request_context_getter_;
+
+ // This is only valid once Initialize() has been called.
scoped_refptr<ChromeAppCacheService> appcache_service_;
+
scoped_ptr<appcache::GetStatusCallback> get_status_callback_;
scoped_ptr<appcache::StartUpdateCallback> start_update_callback_;
scoped_ptr<appcache::SwapCacheCallback> swap_cache_callback_;
diff --git a/chrome/common/appcache/chrome_appcache_service.h b/chrome/common/appcache/chrome_appcache_service.h
index 213a347..37e0dcb 100644
--- a/chrome/common/appcache/chrome_appcache_service.h
+++ b/chrome/common/appcache/chrome_appcache_service.h
@@ -20,52 +20,23 @@
// 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
-// except for the ctor and the init method which are expected to be called on
-// the UI thread.
+// All methods, including the dtor, are expected to be called on the IO thread.
class ChromeAppCacheService
- : public base::RefCountedThreadSafe<ChromeAppCacheService>,
+ : public base::RefCounted<ChromeAppCacheService>,
public appcache::AppCacheService {
public:
- explicit ChromeAppCacheService()
- : is_initialized_(false), was_initialized_with_io_thread_(false) {
- }
-
- bool is_initialized() const { return is_initialized_; }
-
- void InitializeOnUIThread(const FilePath& data_directory,
- bool is_incognito) {
- DCHECK(!is_initialized_);
- is_initialized_ = true;
-
- // The I/O thread may be NULL during testing.
- base::Thread* io_thread = g_browser_process->io_thread();
- if (io_thread) {
- was_initialized_with_io_thread_ = true;
- io_thread->message_loop()->PostTask(FROM_HERE,
- NewRunnableMethod(this, &ChromeAppCacheService::InitializeOnIOThread,
- data_directory, is_incognito));
- }
+ ChromeAppCacheService(const FilePath& data_directory,
+ bool is_incognito) {
+ Initialize(is_incognito ? FilePath()
+ : data_directory.Append(chrome::kAppCacheDirname));
}
-
private:
- friend class base::RefCountedThreadSafe<ChromeAppCacheService>;
+ friend class base::RefCounted<ChromeAppCacheService>;
virtual ~ChromeAppCacheService() {
- DCHECK(!was_initialized_with_io_thread_ ||
- ChromeThread::CurrentlyOn(ChromeThread::IO));
- }
-
- void InitializeOnIOThread(const FilePath& data_directory,
- bool is_incognito) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
- Initialize(is_incognito ? FilePath()
- : data_directory.Append(chrome::kAppCacheDirname));
}
-
- bool is_initialized_;
- bool was_initialized_with_io_thread_;
};
#endif // CHROME_COMMON_APPCACHE_CHROME_APPCACHE_SERVICE_H_