
DownloadService uses the same DownloadIdFactory for an OTR profile as its original profile. DownloadService passes the DownloadIdFactory into the DownloadManager so that the DownloadManager can allocate new valid ids for items loaded from the history or downloads started on the ui thread. Since the DownloadService precedes and outlives its DownloadManager, DownloadManager does not have a scoped_refptr<DownloadIdFactory>. Objects that do have a scoped_refptr<DownloadIdFactory>: DownloadService, ProfileIOData, ShellBrowserContext, ShellResourceContext. The DownloadIdFactory must be RefCountedThreadSafe because ProfileIOData outlives Profile and because it's used in both the OTR and original profiles. Longer term, the import process should strictly precede profile initialization, and the next_download_id counter should be loaded from the History db strictly before DownloadService is created and creates a DownloadIdFactory. BUG=98966 Review URL: http://codereview.chromium.org/8401001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107836 0039d316-1c4b-4281-b951-d872f2087c98
115 lines
3.6 KiB
C++
115 lines
3.6 KiB
C++
// Copyright (c) 2011 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_RESOURCE_CONTEXT_H_
|
|
#define CONTENT_BROWSER_RESOURCE_CONTEXT_H_
|
|
|
|
#include <map>
|
|
|
|
#include "base/basictypes.h"
|
|
#include "base/callback.h"
|
|
#include "base/memory/ref_counted.h"
|
|
#include "content/common/content_export.h"
|
|
|
|
class ChromeAppCacheService;
|
|
class ChromeBlobStorageContext;
|
|
class DownloadIdFactory;
|
|
class ExtensionInfoMap;
|
|
class HostZoomMap;
|
|
class MediaObserver;
|
|
namespace fileapi {
|
|
class FileSystemContext;
|
|
} // namespace fileapi
|
|
namespace media_stream {
|
|
class MediaStreamManager;
|
|
} // namespace media_stream
|
|
namespace net {
|
|
class HostResolver;
|
|
class URLRequestContext;
|
|
} // namespace net
|
|
namespace quota {
|
|
class QuotaManager;
|
|
}; // namespace quota
|
|
namespace webkit_database {
|
|
class DatabaseTracker;
|
|
} // namespace webkit_database
|
|
|
|
namespace content {
|
|
|
|
// ResourceContext contains the relevant context information required for
|
|
// resource loading. It lives on the IO thread, although it is constructed on
|
|
// the UI thread. ResourceContext doesn't own anything it points to, it just
|
|
// holds pointers to relevant objects to resource loading.
|
|
class CONTENT_EXPORT ResourceContext {
|
|
public:
|
|
virtual ~ResourceContext();
|
|
|
|
// The user data allows the clients to associate data with this request.
|
|
// Multiple user data values can be stored under different keys.
|
|
void* GetUserData(const void* key) const;
|
|
void SetUserData(const void* key, void* data);
|
|
|
|
net::HostResolver* host_resolver() const;
|
|
void set_host_resolver(net::HostResolver* host_resolver);
|
|
|
|
net::URLRequestContext* request_context() const;
|
|
void set_request_context(net::URLRequestContext* request_context);
|
|
|
|
ChromeAppCacheService* appcache_service() const;
|
|
void set_appcache_service(ChromeAppCacheService* service);
|
|
|
|
webkit_database::DatabaseTracker* database_tracker() const;
|
|
void set_database_tracker(webkit_database::DatabaseTracker* tracker);
|
|
|
|
fileapi::FileSystemContext* file_system_context() const;
|
|
void set_file_system_context(fileapi::FileSystemContext* context);
|
|
|
|
ChromeBlobStorageContext* blob_storage_context() const;
|
|
void set_blob_storage_context(ChromeBlobStorageContext* context);
|
|
|
|
quota::QuotaManager* quota_manager() const;
|
|
void set_quota_manager(quota::QuotaManager* quota_manager);
|
|
|
|
HostZoomMap* host_zoom_map() const;
|
|
void set_host_zoom_map(HostZoomMap* host_zoom_map);
|
|
|
|
MediaObserver* media_observer() const;
|
|
void set_media_observer(MediaObserver* media_observer);
|
|
|
|
DownloadIdFactory* download_id_factory() const;
|
|
void set_download_id_factory(DownloadIdFactory* download_id_factory);
|
|
|
|
media_stream::MediaStreamManager* media_stream_manager() const;
|
|
void set_media_stream_manager(
|
|
media_stream::MediaStreamManager* media_stream_manager);
|
|
|
|
protected:
|
|
ResourceContext();
|
|
|
|
private:
|
|
virtual void EnsureInitialized() const = 0;
|
|
|
|
net::HostResolver* host_resolver_;
|
|
net::URLRequestContext* request_context_;
|
|
ChromeAppCacheService* appcache_service_;
|
|
webkit_database::DatabaseTracker* database_tracker_;
|
|
fileapi::FileSystemContext* file_system_context_;
|
|
ChromeBlobStorageContext* blob_storage_context_;
|
|
quota::QuotaManager* quota_manager_;
|
|
HostZoomMap* host_zoom_map_;
|
|
MediaObserver* media_observer_;
|
|
DownloadIdFactory* download_id_factory_;
|
|
media_stream::MediaStreamManager* media_stream_manager_;
|
|
|
|
// Externally-defined data accessible by key.
|
|
typedef std::map<const void*, void*> UserDataMap;
|
|
UserDataMap user_data_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ResourceContext);
|
|
};
|
|
|
|
} // namespace content
|
|
|
|
#endif // CONTENT_BROWSER_RESOURCE_CONTEXT_H_
|