| Index: content/browser/websocket/websocket_impl.h
|
| diff --git a/content/browser/websocket/websocket_impl.h b/content/browser/websocket/websocket_impl.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b8193c9e9221d75d7baede8aadce23643cde6497
|
| --- /dev/null
|
| +++ b/content/browser/websocket/websocket_impl.h
|
| @@ -0,0 +1,125 @@
|
| +// Copyright 2013 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_BROWSER_WEBSOCKET_WEBSOCKET_IMPL_H_
|
| +#define CONTENT_BROWSER_WEBSOCKET_WEBSOCKET_IMPL_H_
|
| +
|
| +#include <stdint.h>
|
| +
|
| +#include <memory>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/time/time.h"
|
| +#include "content/common/content_export.h"
|
| +#include "content/common/websocket.mojom.h"
|
| +#include "mojo/public/cpp/bindings/binding.h"
|
| +
|
| +class GURL;
|
| +
|
| +namespace url {
|
| +class Origin;
|
| +} // namespace url
|
| +
|
| +namespace net {
|
| +class WebSocketChannel;
|
| +class URLRequestContext;
|
| +} // namespace net
|
| +
|
| +namespace IPC {
|
| +class Message;
|
| +} // namespace IPC
|
| +
|
| +namespace storage {
|
| +class BlobStorageContext;
|
| +}
|
| +
|
| +namespace content {
|
| +class StoragePartition;
|
| +class WebSocketBlobSender;
|
| +
|
| +// Host of net::WebSocketChannel.
|
| +class CONTENT_EXPORT WebSocketImpl : public mojom::WebSocket {
|
| + public:
|
| + class Delegate {
|
| + public:
|
| + virtual ~Delegate() {}
|
| + virtual int GetClientProcessId() = 0;
|
| + virtual StoragePartition* GetStoragePartition() = 0;
|
| + virtual storage::BlobStorageContext* GetBlobStorageContext() = 0;
|
| + virtual void OnReceivedResponseFromServer(WebSocketImpl* impl) = 0;
|
| + virtual void OnLostConnectionToClient(WebSocketImpl* impl) = 0;
|
| + };
|
| +
|
| + WebSocketImpl(Delegate* delegate,
|
| + mojom::WebSocketRequest request,
|
| + int render_frame_id,
|
| + base::TimeDelta delay);
|
| + ~WebSocketImpl() override;
|
| +
|
| + // mojom::WebSocket methods:
|
| +
|
| + // The renderer process is going away.
|
| + // This function is virtual for testing.
|
| + virtual void GoAway();
|
| +
|
| + // mojom::WebSocket methods:
|
| + void Initialize(mojom::WebSocketClientPtr client) override;
|
| + void AddChannelRequest(const GURL& url,
|
| + mojo::Array<mojo::String> requested_protocols,
|
| + const url::Origin& origin) override;
|
| + void SendBlob(const mojo::String& uuid, uint64_t expected_size) override;
|
| + void SendFrame(bool fin, mojom::WebSocketMessageType type,
|
| + mojo::Array<uint8_t> data) override;
|
| + void SendFlowControl(int64_t quota) override;
|
| + void StartClosingHandshake(uint16_t code,
|
| + const mojo::String& reason) override;
|
| +
|
| + bool handshake_succeeded() const { return handshake_succeeded_; }
|
| + void OnHandshakeSucceeded() { handshake_succeeded_ = true; }
|
| +
|
| + private:
|
| + class WebSocketEventHandler;
|
| +
|
| + void OnConnectionError();
|
| + void AddChannel(const GURL& socket_url,
|
| + const std::vector<std::string>& requested_protocols,
|
| + const url::Origin& origin);
|
| + void BlobSendComplete(int result);
|
| +
|
| + Delegate* delegate_;
|
| + mojo::Binding<mojom::WebSocket> binding_;
|
| +
|
| + mojom::WebSocketClientPtr client_;
|
| +
|
| + int render_frame_id_;
|
| +
|
| + // non-NULL if and only if this object is currently in "blob sending mode".
|
| + std::unique_ptr<WebSocketBlobSender> blob_sender_;
|
| +
|
| + // The channel we use to send events to the network.
|
| + std::unique_ptr<net::WebSocketChannel> channel_;
|
| +
|
| + // Delay used for per-renderer WebSocket throttling.
|
| + base::TimeDelta delay_;
|
| +
|
| + // SendFlowControl() is delayed when OnFlowControl() is called before
|
| + // AddChannel() is called.
|
| + // Zero indicates there is no pending SendFlowControl().
|
| + int64_t pending_flow_control_quota_;
|
| +
|
| + // handshake_succeeded_ is set and used by WebSocketDispatcherHost
|
| + // to manage counters for per-renderer WebSocket throttling.
|
| + bool handshake_succeeded_;
|
| +
|
| + base::WeakPtrFactory<WebSocketImpl> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WebSocketImpl);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_WEBSOCKET_WEBSOCKET_IMPL_H_
|
|
|