Commit 29f8841c authored by Han Leon's avatar Han Leon Committed by Commit Bot

[ServiceWorker] Fix jumbo+Win compilation error related to 'PostMessage'

PostMessage is a macro in Windows and depending on whether Windows
headers have been included or not, PostMessage will either be treated as
PostMessage or PostMessageW.

However, our previous CL
https://chromium-review.googlesource.com/c/chromium/src/+/933867
introduced a method just named as 'PostMessage', this caused some
compile/link errors on Windows platform.

This CL renames the method to 'PostMessageToServiceWorker' to fix this.

BUG=772713,813749
TBR=kinuko@chromium.org for mechanical renaming in the mojom file

Change-Id: I16241052e3deb8ba4a5fbb777037eca9904c6279
Reviewed-on: https://chromium-review.googlesource.com/959688
Commit-Queue: Han Leon <leon.han@intel.com>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542741}
parent 1678f310
...@@ -222,8 +222,9 @@ void ServiceWorkerHandle::RegisterIntoDispatcherHost( ...@@ -222,8 +222,9 @@ void ServiceWorkerHandle::RegisterIntoDispatcherHost(
dispatcher_host_->RegisterServiceWorkerHandle(base::WrapUnique(this)); dispatcher_host_->RegisterServiceWorkerHandle(base::WrapUnique(this));
} }
void ServiceWorkerHandle::PostMessage(::blink::TransferableMessage message, void ServiceWorkerHandle::PostMessageToServiceWorker(
const url::Origin& source_origin) { ::blink::TransferableMessage message,
const url::Origin& source_origin) {
// When this method is called the encoded_message inside message could just // When this method is called the encoded_message inside message could just
// point to the IPC message's buffer. But that buffer can become invalid // point to the IPC message's buffer. But that buffer can become invalid
// before the message is passed on to the service worker, so make sure // before the message is passed on to the service worker, so make sure
......
...@@ -10,20 +10,12 @@ ...@@ -10,20 +10,12 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "build/build_config.h"
#include "content/browser/service_worker/service_worker_version.h" #include "content/browser/service_worker/service_worker_version.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/common/service_worker/service_worker_types.h" #include "content/common/service_worker/service_worker_types.h"
#include "mojo/public/cpp/bindings/associated_binding_set.h" #include "mojo/public/cpp/bindings/associated_binding_set.h"
#include "third_party/WebKit/public/mojom/service_worker/service_worker_object.mojom.h" #include "third_party/WebKit/public/mojom/service_worker/service_worker_object.mojom.h"
#if defined(OS_WIN)
// Since PostMessage is a Win32 macro, ensure that it has the same
// value every time this header is parsed. This avoids strange
// compilation and linking errors.
#include "base/win/windows_types.h"
#endif
namespace url { namespace url {
class Origin; class Origin;
} // namespace url } // namespace url
...@@ -91,8 +83,8 @@ class CONTENT_EXPORT ServiceWorkerHandle ...@@ -91,8 +83,8 @@ class CONTENT_EXPORT ServiceWorkerHandle
ServiceWorkerVersion* version); ServiceWorkerVersion* version);
// Implements blink::mojom::ServiceWorkerObjectHost. // Implements blink::mojom::ServiceWorkerObjectHost.
void PostMessage(::blink::TransferableMessage message, void PostMessageToServiceWorker(::blink::TransferableMessage message,
const url::Origin& source_origin) override; const url::Origin& source_origin) override;
void TerminateForTesting(TerminateForTestingCallback callback) override; void TerminateForTesting(TerminateForTestingCallback callback) override;
void DispatchExtendableMessageEvent( void DispatchExtendableMessageEvent(
......
...@@ -38,8 +38,8 @@ class MockServiceWorkerObjectHost ...@@ -38,8 +38,8 @@ class MockServiceWorkerObjectHost
private: private:
// Implements blink::mojom::ServiceWorkerObjectHost. // Implements blink::mojom::ServiceWorkerObjectHost.
void PostMessage(::blink::TransferableMessage message, void PostMessageToServiceWorker(::blink::TransferableMessage message,
const url::Origin& source_origin) override { const url::Origin& source_origin) override {
NOTREACHED(); NOTREACHED();
} }
void TerminateForTesting(TerminateForTestingCallback callback) override { void TerminateForTesting(TerminateForTestingCallback callback) override {
......
...@@ -61,8 +61,8 @@ class MockServiceWorkerObjectHost ...@@ -61,8 +61,8 @@ class MockServiceWorkerObjectHost
private: private:
// Implements blink::mojom::ServiceWorkerObjectHost. // Implements blink::mojom::ServiceWorkerObjectHost.
void PostMessage(::blink::TransferableMessage message, void PostMessageToServiceWorker(::blink::TransferableMessage message,
const url::Origin& source_origin) override { const url::Origin& source_origin) override {
NOTREACHED(); NOTREACHED();
} }
void TerminateForTesting(TerminateForTestingCallback callback) override { void TerminateForTesting(TerminateForTestingCallback callback) override {
......
...@@ -97,9 +97,11 @@ blink::mojom::ServiceWorkerState WebServiceWorkerImpl::GetState() const { ...@@ -97,9 +97,11 @@ blink::mojom::ServiceWorkerState WebServiceWorkerImpl::GetState() const {
return state_; return state_;
} }
void WebServiceWorkerImpl::PostMessage(blink::TransferableMessage message, void WebServiceWorkerImpl::PostMessageToServiceWorker(
const WebSecurityOrigin& source_origin) { blink::TransferableMessage message,
GetObjectHost()->PostMessage(std::move(message), url::Origin(source_origin)); const WebSecurityOrigin& source_origin) {
GetObjectHost()->PostMessageToServiceWorker(std::move(message),
url::Origin(source_origin));
} }
void WebServiceWorkerImpl::TerminateForTesting( void WebServiceWorkerImpl::TerminateForTesting(
......
...@@ -59,8 +59,9 @@ class CONTENT_EXPORT WebServiceWorkerImpl ...@@ -59,8 +59,9 @@ class CONTENT_EXPORT WebServiceWorkerImpl
blink::WebServiceWorkerProxy* Proxy() override; blink::WebServiceWorkerProxy* Proxy() override;
blink::WebURL Url() const override; blink::WebURL Url() const override;
blink::mojom::ServiceWorkerState GetState() const override; blink::mojom::ServiceWorkerState GetState() const override;
void PostMessage(blink::TransferableMessage message, void PostMessageToServiceWorker(
const blink::WebSecurityOrigin& source_origin) override; blink::TransferableMessage message,
const blink::WebSecurityOrigin& source_origin) override;
void TerminateForTesting( void TerminateForTesting(
std::unique_ptr<TerminateForTestingCallback> callback) override; std::unique_ptr<TerminateForTestingCallback> callback) override;
......
...@@ -78,7 +78,7 @@ void ServiceWorker::postMessage(ScriptState* script_state, ...@@ -78,7 +78,7 @@ void ServiceWorker::postMessage(ScriptState* script_state,
return; return;
} }
handle_->ServiceWorker()->PostMessage( handle_->ServiceWorker()->PostMessageToServiceWorker(
ToTransferableMessage(std::move(msg)), ToTransferableMessage(std::move(msg)),
WebSecurityOrigin(GetExecutionContext()->GetSecurityOrigin())); WebSecurityOrigin(GetExecutionContext()->GetSecurityOrigin()));
} }
......
...@@ -43,7 +43,8 @@ interface ServiceWorkerObjectHost { ...@@ -43,7 +43,8 @@ interface ServiceWorkerObjectHost {
// IPC code this is converted from sent the origin in the IPC message, so it // IPC code this is converted from sent the origin in the IPC message, so it
// was kept as a convenience during migration to Mojo, but we should remove it // was kept as a convenience during migration to Mojo, but we should remove it
// now. // now.
PostMessage(TransferableMessage message, url.mojom.Origin source_origin); PostMessageToServiceWorker(TransferableMessage message,
url.mojom.Origin source_origin);
// Tells the browser process to terminate the service worker. Used in layout // Tells the browser process to terminate the service worker. Used in layout
// tests to verify behavior when a service worker isn't running. The callback // tests to verify behavior when a service worker isn't running. The callback
......
...@@ -70,7 +70,8 @@ class WebServiceWorker { ...@@ -70,7 +70,8 @@ class WebServiceWorker {
return mojom::ServiceWorkerState::kUnknown; return mojom::ServiceWorkerState::kUnknown;
} }
virtual void PostMessage(TransferableMessage, const WebSecurityOrigin&) = 0; virtual void PostMessageToServiceWorker(TransferableMessage,
const WebSecurityOrigin&) = 0;
using TerminateForTestingCallback = WebCallbacks<void, void>; using TerminateForTestingCallback = WebCallbacks<void, void>;
virtual void TerminateForTesting( virtual void TerminateForTesting(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment