1 /* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_SHARED_WORKER_H_ 32 #define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_SHARED_WORKER_H_ 33 34 #include <memory> 35 36 #include "base/unguessable_token.h" 37 #include "mojo/public/cpp/system/message_pipe.h" 38 #include "services/network/public/mojom/content_security_policy.mojom-shared.h" 39 #include "services/network/public/mojom/fetch_api.mojom-shared.h" 40 #include "services/network/public/mojom/ip_address_space.mojom-shared.h" 41 #include "third_party/blink/public/common/user_agent/user_agent_metadata.h" 42 #include "third_party/blink/public/mojom/script/script_type.mojom-shared.h" 43 #include "third_party/blink/public/platform/task_type.h" 44 #include "third_party/blink/public/platform/web_common.h" 45 #include "third_party/blink/public/platform/web_security_origin.h" 46 47 namespace blink { 48 49 class MessagePortChannel; 50 class WebString; 51 class WebSharedWorkerClient; 52 class WebURL; 53 struct WebFetchClientSettingsObject; 54 55 // This is the interface to a SharedWorker thread. 56 class BLINK_EXPORT WebSharedWorker { 57 public: ~WebSharedWorker()58 virtual ~WebSharedWorker() {} 59 60 // Instantiate a WebSharedWorker that interacts with the shared worker. 61 // WebSharedWorkerClient given here should own this instance. 62 static std::unique_ptr<WebSharedWorker> Create(WebSharedWorkerClient*); 63 64 virtual void StartWorkerContext( 65 const WebURL& script_url, 66 mojom::ScriptType script_type, 67 network::mojom::CredentialsMode, 68 const WebString& name, 69 WebSecurityOrigin constructor_origin, 70 const WebString& user_agent, 71 const UserAgentMetadata& ua_metadata, 72 const WebString& content_security_policy, 73 network::mojom::ContentSecurityPolicyType, 74 network::mojom::IPAddressSpace, 75 const WebFetchClientSettingsObject& outside_fetch_client_settings_object, 76 const base::UnguessableToken& appcache_host_id, 77 const base::UnguessableToken& devtools_worker_token, 78 mojo::ScopedMessagePipeHandle content_settings_handle, 79 mojo::ScopedMessagePipeHandle browser_interface_broker, 80 bool pause_worker_context_on_start) = 0; 81 82 // Sends a connect event to the SharedWorker context. 83 virtual void Connect(MessagePortChannel) = 0; 84 85 // Invoked to shutdown the worker when there are no more associated documents. 86 // This eventually deletes this instance. 87 virtual void TerminateWorkerContext() = 0; 88 }; 89 90 } // namespace blink 91 92 #endif 93