#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_
#include <set>
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "webkit/common/resource_type.h"
namespace content {
class ServiceWorkerContextCore;
class ServiceWorkerVersion;
class CONTENT_EXPORT ServiceWorkerProviderHost
: public base::SupportsWeakPtr<ServiceWorkerProviderHost> {
public:
ServiceWorkerProviderHost(int process_id,
int provider_id,
base::WeakPtr<ServiceWorkerContextCore> context);
~ServiceWorkerProviderHost();
int process_id() const { return process_id_; }
int provider_id() const { return provider_id_; }
const std::set<int>& script_client_thread_ids() const {
return script_client_thread_ids_;
}
ServiceWorkerVersion* associated_version() const {
return associated_version_.get();
}
ServiceWorkerVersion* hosted_version() const {
return hosted_version_.get();
}
void AddScriptClient(int thread_id);
void RemoveScriptClient(int thread_id);
void AssociateVersion(ServiceWorkerVersion* version);
bool SetHostedVersionId(int64 versions_id);
bool ShouldHandleRequest(ResourceType::Type resource_type) const;
private:
const int process_id_;
const int provider_id_;
std::set<int> script_client_thread_ids_;
scoped_refptr<ServiceWorkerVersion> associated_version_;
scoped_refptr<ServiceWorkerVersion> hosted_version_;
base::WeakPtr<ServiceWorkerContextCore> context_;
};
}
#endif