blob: bde7cbae29609283a681bebbe14d995be1114dc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// Copyright (c) 2012 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_WORKER_WEBSHAREDWORKER_STUB_H_
#define CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_
#include "base/memory/scoped_ptr.h"
#include "content/child/scoped_child_process_reference.h"
#include "content/worker/websharedworkerclient_proxy.h"
#include "content/worker/worker_webapplicationcachehost_impl.h"
#include "ipc/ipc_listener.h"
#include "third_party/WebKit/public/web/WebSharedWorker.h"
#include "url/gurl.h"
namespace blink {
class WebMessagePortChannel;
class WebSharedWorker;
}
namespace content {
class SharedWorkerDevToolsAgent;
class WebMessagePortChannelImpl;
// This class creates a WebSharedWorker, and translates incoming IPCs to the
// appropriate WebSharedWorker APIs.
class WebSharedWorkerStub : public IPC::Listener {
public:
WebSharedWorkerStub(const GURL& url,
const base::string16& name,
const base::string16& content_security_policy,
blink::WebContentSecurityPolicyType security_policy_type,
int route_id,
const WorkerAppCacheInitInfo& appcache_init_info);
// IPC::Listener implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnChannelError() OVERRIDE;
// Invoked when the WebSharedWorkerClientProxy is shutting down.
void Shutdown();
void WorkerScriptLoaded();
void WorkerScriptLoadFailed();
// Called after terminating the worker context to make sure that the worker
// actually terminates (is not stuck in an infinite loop).
void EnsureWorkerContextTerminates();
WebSharedWorkerClientProxy* client() { return &client_; }
const WorkerAppCacheInitInfo& appcache_init_info() const {
return appcache_init_info_;
}
// Returns the script url of this worker.
const GURL& url();
private:
virtual ~WebSharedWorkerStub();
void OnConnect(int sent_message_port_id, int routing_id);
void OnStartWorkerContext(
const GURL& url, const base::string16& user_agent,
const base::string16& source_code,
const base::string16& content_security_policy,
blink::WebContentSecurityPolicyType policy_type);
void OnTerminateWorkerContext();
ScopedChildProcessReference process_ref_;
int route_id_;
WorkerAppCacheInitInfo appcache_init_info_;
// WebSharedWorkerClient that responds to outgoing API calls
// from the worker object.
WebSharedWorkerClientProxy client_;
blink::WebSharedWorker* impl_;
base::string16 name_;
bool started_;
GURL url_;
bool worker_script_loaded_;
scoped_ptr<SharedWorkerDevToolsAgent> worker_devtools_agent_;
typedef std::vector<blink::WebMessagePortChannel*> PendingChannelList;
PendingChannelList pending_channels_;
DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerStub);
};
} // namespace content
#endif // CONTENT_WORKER_WEBSHAREDWORKER_STUB_H_
|