Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / net / tools / quic / quic_in_memory_cache.h
index 3be25a6..e625e17 100644 (file)
@@ -32,12 +32,19 @@ class QuicServer;
 // `wget -p --save_headers <url>`
 class QuicInMemoryCache {
  public:
+  enum SpecialResponseType {
+    REGULAR_RESPONSE,  // Send the headers and body like a server should.
+    CLOSE_CONNECTION,  // Close the connection (sending the close packet).
+    IGNORE_REQUEST,  // Do nothing, expect the client to time out.
+  };
+
   // Container for response header/body pairs.
   class Response {
    public:
-    Response() {}
+    Response() : response_type_(REGULAR_RESPONSE) {}
     ~Response() {}
 
+    SpecialResponseType response_type() const { return response_type_; }
     const BalsaHeaders& headers() const { return headers_; }
     const base::StringPiece body() const { return base::StringPiece(body_); }
 
@@ -51,6 +58,7 @@ class QuicInMemoryCache {
       body.CopyToString(&body_);
     }
 
+    SpecialResponseType response_type_;
     BalsaHeaders headers_;
     std::string body_;
 
@@ -61,7 +69,7 @@ class QuicInMemoryCache {
   static QuicInMemoryCache* GetInstance();
 
   // Retrieve a response from this cache for a given request.
-  // If no appropriate response exists, NULL is returned.
+  // If no appropriate response exists, nullptr is returned.
   // Currently, responses are selected based on request URI only.
   const Response* GetResponse(const BalsaHeaders& request_headers) const;
 
@@ -79,6 +87,12 @@ class QuicInMemoryCache {
                    const BalsaHeaders& response_headers,
                    base::StringPiece response_body);
 
+  // Simulate a special behavior at a particular path.
+  void AddSpecialResponse(base::StringPiece method,
+                          base::StringPiece path,
+                          base::StringPiece version,
+                          SpecialResponseType response_type);
+
  private:
   typedef base::hash_map<std::string, Response*> ResponseMap;
   friend struct DefaultSingletonTraits<QuicInMemoryCache>;