OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. 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. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_EXECUTABLE_HANDLER_IMPL_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "content/browser/worker_host/worker_storage_partition.h" |
| 11 #include "content/public/browser/worker_service_observer.h" |
| 12 #include "webkit/browser/appcache/appcache_executable_handler.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 class ChromeBlobStorageContext; |
| 17 class ResourceContext; |
| 18 class WorkerStoragePartition; |
| 19 |
| 20 class AppCacheExecutableHandlerFactoryImpl |
| 21 : public appcache::AppCacheExecutableHandlerFactory { |
| 22 public: |
| 23 AppCacheExecutableHandlerFactoryImpl( |
| 24 ResourceContext* resource_context, |
| 25 const WorkerStoragePartition& partition, |
| 26 ChromeBlobStorageContext* blob_context); |
| 27 virtual ~AppCacheExecutableHandlerFactoryImpl(); |
| 28 virtual scoped_ptr<appcache::AppCacheExecutableHandler> CreateHandler( |
| 29 int64 appcache_id, |
| 30 const GURL& handler_url, |
| 31 const std::string& raw_handler_source) OVERRIDE; |
| 32 |
| 33 virtual fileapi::FileSystemContext* GetFileSystemContext() OVERRIDE; |
| 34 virtual webkit_blob::BlobStorageController* GetBlobStorageController() |
| 35 OVERRIDE; |
| 36 |
| 37 private: |
| 38 ResourceContext* resource_context_; |
| 39 ChromeAppCacheService* appcache_service_; |
| 40 WorkerStoragePartition partition_; |
| 41 scoped_refptr<ChromeBlobStorageContext> blob_context_; |
| 42 |
| 43 DISALLOW_COPY_AND_ASSIGN(AppCacheExecutableHandlerFactoryImpl); |
| 44 }; |
| 45 |
| 46 class AppCacheExecutableHandlerImpl |
| 47 : public appcache::AppCacheExecutableHandler, |
| 48 public WorkerServiceObserver { |
| 49 public: |
| 50 virtual ~AppCacheExecutableHandlerImpl(); |
| 51 virtual void HandleRequest(const Request& req, |
| 52 ResponseCallback user_callback) OVERRIDE; |
| 53 |
| 54 // Called the a message filter to plumb the exe handler's response |
| 55 // back to our caller. |
| 56 static void ProcessResponse(int request_id, const Response& resp); |
| 57 |
| 58 // WorkerServiceObserver methods |
| 59 virtual void WorkerDestroyed(int process_id, int route_id) OVERRIDE; |
| 60 |
| 61 private: |
| 62 friend class AppCacheExecutableHandlerFactoryImpl; |
| 63 AppCacheExecutableHandlerImpl( |
| 64 int64 appcache_id, |
| 65 const GURL& handler_url, |
| 66 const std::string& raw_handler_source, |
| 67 ResourceContext* resource_context, |
| 68 ChromeAppCacheService* appcache_service, |
| 69 WorkerStoragePartition* partition); |
| 70 AppCacheExecutableHandlerImpl(); |
| 71 |
| 72 void EnsureWorkerStarted(); |
| 73 void CallbackAdapter(int request_id, ResponseCallback user_callback, |
| 74 const Response& resp); |
| 75 void ClearCallbacks(); |
| 76 |
| 77 int worker_route_id_; |
| 78 |
| 79 // all needed to restart the worker in case it goes down |
| 80 const int64 appcache_id_; |
| 81 const GURL handler_url_; |
| 82 const std::string raw_handler_source_; |
| 83 |
| 84 // these is ugly and depends on the factory outliving the handler |
| 85 ResourceContext* resource_context_; // could be const? |
| 86 ChromeAppCacheService* appcache_service_; |
| 87 const WorkerStoragePartition* partition_; |
| 88 |
| 89 // needed for cleanup on destruction or when the thread dies |
| 90 std::set<int> pending_request_ids_; |
| 91 DISALLOW_COPY_AND_ASSIGN(AppCacheExecutableHandlerImpl); |
| 92 }; |
| 93 |
| 94 } // namespace content |
| 95 |
| 96 #endif // CONTENT_BROWSER_APPCACHE_CHROME_APPCACHE_SERVICE_H_ |
OLD | NEW |