1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_COMMON_WEBSOCKET_H_
6#define CONTENT_COMMON_WEBSOCKET_H_
7
8#include <string>
9#include <utility>
10#include <vector>
11
12#include "base/time/time.h"
13#include "url/gurl.h"
14
15namespace content {
16
17// WebSocket data message types sent between the browser and renderer processes.
18enum WebSocketMessageType {
19  WEB_SOCKET_MESSAGE_TYPE_CONTINUATION = 0x0,
20  WEB_SOCKET_MESSAGE_TYPE_TEXT = 0x1,
21  WEB_SOCKET_MESSAGE_TYPE_BINARY = 0x2,
22  WEB_SOCKET_MESSAGE_TYPE_LAST = WEB_SOCKET_MESSAGE_TYPE_BINARY
23};
24
25// Opening handshake request information which will be shown in the inspector.
26// All string data should be encoded to ASCII in the browser process.
27struct WebSocketHandshakeRequest {
28  WebSocketHandshakeRequest();
29  ~WebSocketHandshakeRequest();
30
31  // The request URL
32  GURL url;
33  // Additional HTTP request headers
34  std::vector<std::pair<std::string, std::string> > headers;
35  // HTTP request headers raw string
36  std::string headers_text;
37  // The time that this request is sent
38  base::Time request_time;
39};
40
41// Opening handshake response information which will be shown in the inspector.
42// All string data should be encoded to ASCII in the browser process.
43struct WebSocketHandshakeResponse {
44  WebSocketHandshakeResponse();
45  ~WebSocketHandshakeResponse();
46
47  // The request URL
48  GURL url;
49  // HTTP status code
50  int status_code;
51  // HTTP status text
52  std::string status_text;
53  // Additional HTTP response headers
54  std::vector<std::pair<std::string, std::string> > headers;
55  // HTTP response headers raw string
56  std::string headers_text;
57  // The time that this response arrives
58  base::Time response_time;
59};
60
61}  // namespace content
62
63#endif  // CONTENT_COMMON_WEBSOCKET_H_
64