1 // Copyright (c) 2012 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_WORKER_HOST_WORKER_STORAGE_PARTITION_H_ 6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_STORAGE_PARTITION_H_ 7 8 #include "base/memory/ref_counted.h" 9 10 namespace quota { 11 class QuotaManager; 12 } 13 14 namespace fileapi { 15 class FileSystemContext; 16 } // namespace fileapi 17 18 namespace net { 19 class URLRequestContextGetter; 20 } 21 22 namespace webkit_database { 23 class DatabaseTracker; 24 } // namespace webkit_database 25 26 namespace content { 27 class ChromeAppCacheService; 28 class IndexedDBContextImpl; 29 30 // Contains the data from StoragePartition for use by Worker APIs. 31 // 32 // StoragePartition meant for the UI so we can't use it directly in many 33 // Worker APIs that run on the IO thread. While we could make it RefCounted, 34 // the Worker system is the only place that really needs access on the IO 35 // thread. Instead of changing the lifetime semantics of StoragePartition, 36 // we just create a parallel struct here to simplify the APIs of various 37 // methods in WorkerServiceImpl. 38 // 39 // This class is effectively a struct, but we make it a class because we want to 40 // define copy constructors, assignment operators, and an Equals() function for 41 // it which makes it look awkward as a struct. 42 class WorkerStoragePartition { 43 public: 44 WorkerStoragePartition( 45 net::URLRequestContextGetter* url_request_context, 46 net::URLRequestContextGetter* media_url_request_context, 47 ChromeAppCacheService* appcache_service, 48 quota::QuotaManager* quota_manager, 49 fileapi::FileSystemContext* filesystem_context, 50 webkit_database::DatabaseTracker* database_tracker, 51 IndexedDBContextImpl* indexed_db_context); 52 ~WorkerStoragePartition(); 53 54 // Declaring so these don't get inlined which has the unfortunate effect of 55 // requiring all including classes to have the full definition of every member 56 // type. 57 WorkerStoragePartition(const WorkerStoragePartition& other); 58 const WorkerStoragePartition& operator=(const WorkerStoragePartition& rhs); 59 60 bool Equals(const WorkerStoragePartition& other) const; 61 62 net::URLRequestContextGetter* url_request_context() const { 63 return url_request_context_.get(); 64 } 65 66 net::URLRequestContextGetter* media_url_request_context() const { 67 return media_url_request_context_.get(); 68 } 69 70 ChromeAppCacheService* appcache_service() const { 71 return appcache_service_.get(); 72 } 73 74 quota::QuotaManager* quota_manager() const { 75 return quota_manager_.get(); 76 } 77 78 fileapi::FileSystemContext* filesystem_context() const { 79 return filesystem_context_.get(); 80 } 81 82 webkit_database::DatabaseTracker* database_tracker() const { 83 return database_tracker_.get(); 84 } 85 86 IndexedDBContextImpl* indexed_db_context() const { 87 return indexed_db_context_.get(); 88 } 89 90 private: 91 void Copy(const WorkerStoragePartition& other); 92 93 scoped_refptr<net::URLRequestContextGetter> url_request_context_; 94 scoped_refptr<net::URLRequestContextGetter> media_url_request_context_; 95 scoped_refptr<ChromeAppCacheService> appcache_service_; 96 scoped_refptr<quota::QuotaManager> quota_manager_; 97 scoped_refptr<fileapi::FileSystemContext> filesystem_context_; 98 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; 99 scoped_refptr<IndexedDBContextImpl> indexed_db_context_; 100 }; 101 102 } // namespace content 103 104 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_STORAGE_PARTITION_H_ 105