Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // WebSocketHandshakeThrottle provides a facility for embedders to delay | 5 // WebSocketHandshakeThrottle provides a facility for embedders to delay |
| 6 // WebSocket connection establishment. Specifically, at the same time as the | 6 // WebSocket connection establishment. Specifically, at the same time as the |
| 7 // handshake is started blink::Platform::CreateWebSocketHandshakeThrottle() will | 7 // handshake is started blink::Platform::CreateWebSocketHandshakeThrottle() will |
| 8 // be called. If a non-null WebSocketHandshakeThrottle is returned then | 8 // be called. If a non-null WebSocketHandshakeThrottle is returned then |
| 9 // ThrottleHandshake() will be called on it. If the result is error then the | 9 // ThrottleHandshake() will be called on it. If the result is error then the |
| 10 // handshake will be aborted, and a connection error will be reported to | 10 // handshake will be aborted, and a connection error will be reported to |
| 11 // Javascript. If the throttle hasn't reported a result when the WebSocket | 11 // Javascript. If the throttle hasn't reported a result when the WebSocket |
| 12 // handshake succeeds then Blink will wait for the throttle result before | 12 // handshake succeeds then Blink will wait for the throttle result before |
| 13 // reporting the connection is open to Javascript. | 13 // reporting the connection is open to Javascript. |
| 14 | 14 |
| 15 #ifndef WebSocketHandshakeThrottle_h | 15 #ifndef WebSocketHandshakeThrottle_h |
| 16 #define WebSocketHandshakeThrottle_h | 16 #define WebSocketHandshakeThrottle_h |
| 17 | 17 |
| 18 #include "public/platform/WebCallbacks.h" | 18 #include "WebCallbacks.h" |
|
kinuko
2017/06/21 06:42:42
I think writing this way was preferable (while not
Adam Rice
2017/06/21 07:43:20
Yes. websocket_sb_handshake_throttle.h in //compon
kinuko
2017/06/21 08:59:35
Adding //third_party/WebKit/public:blink_header to
Adam Rice
2017/06/21 09:18:47
I see. It must have got better when I fixed the DE
| |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 class WebURL; | 22 class WebURL; |
| 23 class WebLocalFrame; | 23 class WebLocalFrame; |
| 24 class WebString; | 24 class WebString; |
| 25 | 25 |
| 26 // Embedders can implement this class to delay WebSocket connections. | 26 // Embedders can implement this class to delay WebSocket connections. |
| 27 class WebSocketHandshakeThrottle { | 27 class WebSocketHandshakeThrottle { |
| 28 public: | 28 public: |
| 29 // Destruction implies that the handshake has been aborted. Any ongoing work | 29 // Destruction implies that the handshake has been aborted. Any ongoing work |
| 30 // should be cleaned up if possible. | 30 // should be cleaned up if possible. |
| 31 virtual ~WebSocketHandshakeThrottle() {} | 31 virtual ~WebSocketHandshakeThrottle() {} |
| 32 | 32 |
| 33 // The WebCallbacks OnSuccess or OnError should be called asychronously to | 33 // The WebCallbacks OnSuccess or OnError should be called asychronously to |
| 34 // permit Javascript to use the connection or not. OnError should be passed | 34 // permit Javascript to use the connection or not. OnError should be passed |
| 35 // a message to be displayed on the console indicating why the handshake was | 35 // a message to be displayed on the console indicating why the handshake was |
| 36 // blocked. This object will be destroyed synchronously inside the | 36 // blocked. This object will be destroyed synchronously inside the |
| 37 // callbacks. Callbacks must not be called after this object has been | 37 // callbacks. Callbacks must not be called after this object has been |
| 38 // destroyed. | 38 // destroyed. |
| 39 virtual void ThrottleHandshake(const WebURL&, | 39 virtual void ThrottleHandshake(const WebURL&, |
| 40 WebLocalFrame*, | 40 WebLocalFrame*, |
| 41 WebCallbacks<void, const WebString&>*) = 0; | 41 WebCallbacks<void, const WebString&>*) = 0; |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 } // namespace blink | 44 } // namespace blink |
| 45 | 45 |
| 46 #endif // WebSocketHandshakeThrottle_h | 46 #endif // WebSocketHandshakeThrottle_h |
| OLD | NEW |