Index: content/browser/appcache/appcache_executable_handler_impl.h |
diff --git a/content/browser/appcache/appcache_executable_handler_impl.h b/content/browser/appcache/appcache_executable_handler_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d29eba8634f91539c46776cda6df6e7b9d7580cd |
--- /dev/null |
+++ b/content/browser/appcache/appcache_executable_handler_impl.h |
@@ -0,0 +1,96 @@ |
+// Copyright (c) 2013 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. |
+ |
+#ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_IMPL_H_ |
+#define CONTENT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_IMPL_H_ |
+ |
+#include <set> |
+ |
+#include "content/browser/worker_host/worker_storage_partition.h" |
+#include "content/public/browser/worker_service_observer.h" |
+#include "webkit/browser/appcache/appcache_executable_handler.h" |
+ |
+namespace content { |
+ |
+class ChromeBlobStorageContext; |
+class ResourceContext; |
+class WorkerStoragePartition; |
+ |
+class AppCacheExecutableHandlerFactoryImpl |
+ : public appcache::AppCacheExecutableHandlerFactory { |
+ public: |
+ AppCacheExecutableHandlerFactoryImpl( |
+ ResourceContext* resource_context, |
+ const WorkerStoragePartition& partition, |
+ ChromeBlobStorageContext* blob_context); |
+ virtual ~AppCacheExecutableHandlerFactoryImpl(); |
+ virtual scoped_ptr<appcache::AppCacheExecutableHandler> CreateHandler( |
+ int64 appcache_id, |
+ const GURL& handler_url, |
+ const std::string& raw_handler_source) OVERRIDE; |
+ |
+ virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; |
+ virtual webkit_blob::BlobStorageController* GetBlobStorageController() |
+ OVERRIDE; |
+ |
+ private: |
+ ResourceContext* resource_context_; |
+ ChromeAppCacheService* appcache_service_; |
+ WorkerStoragePartition partition_; |
+ scoped_refptr<ChromeBlobStorageContext> blob_context_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AppCacheExecutableHandlerFactoryImpl); |
+}; |
+ |
+class AppCacheExecutableHandlerImpl |
+ : public appcache::AppCacheExecutableHandler, |
+ public WorkerServiceObserver { |
+ public: |
+ virtual ~AppCacheExecutableHandlerImpl(); |
+ virtual void HandleRequest(const Request& req, |
+ ResponseCallback user_callback) OVERRIDE; |
+ |
+ // Called the a message filter to plumb the exe handler's response |
+ // back to our caller. |
+ static void ProcessResponse(int request_id, const Response& resp); |
+ |
+ // WorkerServiceObserver methods |
+ virtual void WorkerDestroyed(int process_id, int route_id) OVERRIDE; |
+ |
+ private: |
+ friend class AppCacheExecutableHandlerFactoryImpl; |
+ AppCacheExecutableHandlerImpl( |
+ int64 appcache_id, |
+ const GURL& handler_url, |
+ const std::string& raw_handler_source, |
+ ResourceContext* resource_context, |
+ ChromeAppCacheService* appcache_service, |
+ WorkerStoragePartition* partition); |
+ AppCacheExecutableHandlerImpl(); |
+ |
+ void EnsureWorkerStarted(); |
+ void CallbackAdapter(int request_id, ResponseCallback user_callback, |
+ const Response& resp); |
+ void ClearCallbacks(); |
+ |
+ int worker_route_id_; |
+ |
+ // all needed to restart the worker in case it goes down |
+ const int64 appcache_id_; |
+ const GURL handler_url_; |
+ const std::string raw_handler_source_; |
+ |
+ // these is ugly and depends on the factory outliving the handler |
+ ResourceContext* resource_context_; // could be const? |
+ ChromeAppCacheService* appcache_service_; |
+ const WorkerStoragePartition* partition_; |
+ |
+ // needed for cleanup on destruction or when the thread dies |
+ std::set<int> pending_request_ids_; |
+ DISALLOW_COPY_AND_ASSIGN(AppCacheExecutableHandlerImpl); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ |