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