#ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_
#define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_SCRIPT_CONTEXT_H_
#include <vector>
#include "base/basictypes.h"
#include "base/strings/string16.h"
#include "content/common/service_worker/service_worker_types.h"
#include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h"
namespace blink {
class WebServiceWorkerContextProxy;
}
namespace IPC {
class Message;
}
namespace content {
class EmbeddedWorkerContextClient;
class ServiceWorkerScriptContext {
public:
ServiceWorkerScriptContext(
EmbeddedWorkerContextClient* embedded_context,
blink::WebServiceWorkerContextProxy* proxy);
~ServiceWorkerScriptContext();
void OnMessageReceived(int request_id, const IPC::Message& message);
void DidHandleActivateEvent(int request_id,
blink::WebServiceWorkerEventResult);
void DidHandleInstallEvent(int request_id,
blink::WebServiceWorkerEventResult result);
void DidHandleFetchEvent(int request_id,
ServiceWorkerFetchEventResult result,
const ServiceWorkerResponse& response);
void DidHandleSyncEvent(int request_id);
private:
void Send(int request_id, const IPC::Message& message);
void OnActivateEvent();
void OnInstallEvent(int active_version_id);
void OnFetchEvent(const ServiceWorkerFetchRequest& request);
void OnPostMessage(const base::string16& message,
const std::vector<int>& sent_message_port_ids,
const std::vector<int>& new_routing_ids);
void OnSyncEvent();
EmbeddedWorkerContextClient* embedded_context_;
blink::WebServiceWorkerContextProxy* proxy_;
int current_request_id_;
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerScriptContext);
};
}
#endif