Merge from Chromium at DEPS revision 228962

This commit was generated by merge_to_master.py.

Change-Id: I23bd7d7766f213fd52f28ae5e1ecc6ae9df905ea
diff --git a/net/tools/DEPS b/net/tools/DEPS
index 90fa4c0..1ea12e4 100644
--- a/net/tools/DEPS
+++ b/net/tools/DEPS
@@ -1,3 +1,4 @@
 skip_child_includes = [
+  "balsa",
   "flip_server",
 ]
diff --git a/net/tools/flip_server/balsa_enums.h b/net/tools/balsa/balsa_enums.h
similarity index 94%
rename from net/tools/flip_server/balsa_enums.h
rename to net/tools/balsa/balsa_enums.h
index 4273ee4..a59dcda 100644
--- a/net/tools/flip_server/balsa_enums.h
+++ b/net/tools/balsa/balsa_enums.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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 NET_TOOLS_FLIP_SERVER_BALSA_ENUMS_H_
-#define NET_TOOLS_FLIP_SERVER_BALSA_ENUMS_H_
+#ifndef NET_TOOLS_BALSA_BALSA_ENUMS_H_
+#define NET_TOOLS_BALSA_BALSA_ENUMS_H_
 
 namespace net {
 
@@ -107,5 +107,5 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_BALSA_ENUMS_H_
+#endif  // NET_TOOLS_BALSA_BALSA_ENUMS_H_
 
diff --git a/net/tools/flip_server/balsa_frame.cc b/net/tools/balsa/balsa_frame.cc
similarity index 98%
rename from net/tools/flip_server/balsa_frame.cc
rename to net/tools/balsa/balsa_frame.cc
index dead665..1103ef1 100644
--- a/net/tools/flip_server/balsa_frame.cc
+++ b/net/tools/balsa/balsa_frame.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
 
-#include "net/tools/flip_server/balsa_frame.h"
+#include "net/tools/balsa/balsa_frame.h"
 
 #include <assert.h>
 #if __SSE2__
@@ -18,13 +18,13 @@
 #include "base/logging.h"
 #include "base/port.h"
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_enums.h"
-#include "net/tools/flip_server/balsa_headers.h"
-#include "net/tools/flip_server/balsa_visitor_interface.h"
-#include "net/tools/flip_server/buffer_interface.h"
-#include "net/tools/flip_server/simple_buffer.h"
-#include "net/tools/flip_server/split.h"
-#include "net/tools/flip_server/string_piece_utils.h"
+#include "net/tools/balsa/balsa_enums.h"
+#include "net/tools/balsa/balsa_headers.h"
+#include "net/tools/balsa/balsa_visitor_interface.h"
+#include "net/tools/balsa/buffer_interface.h"
+#include "net/tools/balsa/simple_buffer.h"
+#include "net/tools/balsa/split.h"
+#include "net/tools/balsa/string_piece_utils.h"
 
 namespace net {
 
diff --git a/net/tools/flip_server/balsa_frame.h b/net/tools/balsa/balsa_frame.h
similarity index 94%
rename from net/tools/flip_server/balsa_frame.h
rename to net/tools/balsa/balsa_frame.h
index 0d3b372..8e1240c 100644
--- a/net/tools/flip_server/balsa_frame.h
+++ b/net/tools/balsa/balsa_frame.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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 NET_TOOLS_FLIP_SERVER_BALSA_FRAME_H_
-#define NET_TOOLS_FLIP_SERVER_BALSA_FRAME_H_
+#ifndef NET_TOOLS_BALSA_BALSA_FRAME_H_
+#define NET_TOOLS_BALSA_BALSA_FRAME_H_
 
 #include <strings.h>
 
@@ -12,12 +12,12 @@
 
 #include "base/compiler_specific.h"
 #include "base/port.h"
-#include "net/tools/flip_server/balsa_enums.h"
-#include "net/tools/flip_server/balsa_headers.h"
-#include "net/tools/flip_server/balsa_visitor_interface.h"
-#include "net/tools/flip_server/buffer_interface.h"
-#include "net/tools/flip_server/http_message_constants.h"
-#include "net/tools/flip_server/simple_buffer.h"
+#include "net/tools/balsa/balsa_enums.h"
+#include "net/tools/balsa/balsa_headers.h"
+#include "net/tools/balsa/balsa_visitor_interface.h"
+#include "net/tools/balsa/buffer_interface.h"
+#include "net/tools/balsa/http_message_constants.h"
+#include "net/tools/balsa/simple_buffer.h"
 
 // For additional debug output, uncomment the following:
 // #define DEBUGFRAMER 1
@@ -261,5 +261,5 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_BALSA_FRAME_H_
+#endif  // NET_TOOLS_BALSA_BALSA_FRAME_H_
 
diff --git a/net/tools/flip_server/balsa_frame_test.cc b/net/tools/balsa/balsa_frame_test.cc
similarity index 98%
rename from net/tools/flip_server/balsa_frame_test.cc
rename to net/tools/balsa/balsa_frame_test.cc
index 3bb9a42..2582721 100644
--- a/net/tools/flip_server/balsa_frame_test.cc
+++ b/net/tools/balsa/balsa_frame_test.cc
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "net/tools/flip_server/balsa_frame.h"
+#include "net/tools/balsa/balsa_frame.h"
 
 #include <iterator>
 
 #include "base/memory/scoped_ptr.h"
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_enums.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_enums.h"
+#include "net/tools/balsa/balsa_headers.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
diff --git a/net/tools/flip_server/balsa_headers.cc b/net/tools/balsa/balsa_headers.cc
similarity index 98%
rename from net/tools/flip_server/balsa_headers.cc
rename to net/tools/balsa/balsa_headers.cc
index 040c012..27bfd24 100644
--- a/net/tools/flip_server/balsa_headers.cc
+++ b/net/tools/balsa/balsa_headers.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
 
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 
 #include <stdio.h>
 #include <algorithm>
@@ -13,14 +13,12 @@
 
 #include "base/logging.h"
 #include "base/port.h"
-#include "base/strings/stringprintf.h"
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_enums.h"
-#include "net/tools/flip_server/buffer_interface.h"
-#include "net/tools/flip_server/simple_buffer.h"
+#include "base/strings/stringprintf.h"
+#include "net/tools/balsa/balsa_enums.h"
+#include "net/tools/balsa/buffer_interface.h"
+#include "net/tools/balsa/simple_buffer.h"
 #include "third_party/tcmalloc/chromium/src/base/googleinit.h"
-// #include "util/gtl/iterator_adaptors-inl.h"
-// #include "util/gtl/map-util.h"
 
 namespace {
 
diff --git a/net/tools/flip_server/balsa_headers.h b/net/tools/balsa/balsa_headers.h
similarity index 98%
rename from net/tools/flip_server/balsa_headers.h
rename to net/tools/balsa/balsa_headers.h
index 2c8b083..47cf388 100644
--- a/net/tools/flip_server/balsa_headers.h
+++ b/net/tools/balsa/balsa_headers.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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 NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_
-#define NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_
+#ifndef NET_TOOLS_BALSA_BALSA_HEADERS_H_
+#define NET_TOOLS_BALSA_BALSA_HEADERS_H_
 
 #include <algorithm>
 #include <iosfwd>
@@ -15,8 +15,8 @@
 #include "base/logging.h"
 #include "base/port.h"
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_enums.h"
-#include "net/tools/flip_server/string_piece_utils.h"
+#include "net/tools/balsa/balsa_enums.h"
+#include "net/tools/balsa/string_piece_utils.h"
 
 namespace net {
 
@@ -1135,4 +1135,4 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_H_
+#endif  // NET_TOOLS_BALSA_BALSA_HEADERS_H_
diff --git a/net/tools/flip_server/balsa_headers_test.cc b/net/tools/balsa/balsa_headers_test.cc
similarity index 98%
rename from net/tools/flip_server/balsa_headers_test.cc
rename to net/tools/balsa/balsa_headers_test.cc
index 241fee1..da2ad19 100644
--- a/net/tools/flip_server/balsa_headers_test.cc
+++ b/net/tools/balsa/balsa_headers_test.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 
 #include <iterator>
 #include <string>
@@ -10,7 +10,7 @@
 
 #include "base/memory/scoped_ptr.h"
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_enums.h"
+#include "net/tools/balsa/balsa_enums.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace net {
diff --git a/net/tools/flip_server/balsa_headers_token_utils.cc b/net/tools/balsa/balsa_headers_token_utils.cc
similarity index 95%
rename from net/tools/flip_server/balsa_headers_token_utils.cc
rename to net/tools/balsa/balsa_headers_token_utils.cc
index b47debf..c807e05 100644
--- a/net/tools/flip_server/balsa_headers_token_utils.cc
+++ b/net/tools/balsa/balsa_headers_token_utils.cc
@@ -1,9 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
 
-#include "net/tools/flip_server/balsa_headers_token_utils.h"
-#include "net/tools/flip_server/string_piece_utils.h"
+#include "net/tools/balsa/balsa_headers_token_utils.h"
+#include "net/tools/balsa/string_piece_utils.h"
 
 namespace net {
 
diff --git a/net/tools/flip_server/balsa_headers_token_utils.h b/net/tools/balsa/balsa_headers_token_utils.h
similarity index 88%
rename from net/tools/flip_server/balsa_headers_token_utils.h
rename to net/tools/balsa/balsa_headers_token_utils.h
index f50c606..aaa0e30 100644
--- a/net/tools/flip_server/balsa_headers_token_utils.h
+++ b/net/tools/balsa/balsa_headers_token_utils.h
@@ -1,15 +1,15 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
 
 // Utility class that performs basic operations on header value tokens: parsing
 // them out, checking for presense of certain tokens, and removing them.
 
-#ifndef NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_TOKEN_UTILS_H_
-#define NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_TOKEN_UTILS_H_
+#ifndef NET_TOOLS_BALSA_BALSA_HEADERS_TOKEN_UTILS_H_
+#define NET_TOOLS_BALSA_BALSA_HEADERS_TOKEN_UTILS_H_
 
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 
 namespace net {
 
@@ -57,5 +57,5 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_BALSA_HEADERS_TOKEN_UTILS_H_
+#endif  // NET_TOOLS_BALSA_BALSA_HEADERS_TOKEN_UTILS_H_
 
diff --git a/net/tools/flip_server/balsa_visitor_interface.h b/net/tools/balsa/balsa_visitor_interface.h
similarity index 96%
rename from net/tools/flip_server/balsa_visitor_interface.h
rename to net/tools/balsa/balsa_visitor_interface.h
index 75283ac..1f24e6d 100644
--- a/net/tools/flip_server/balsa_visitor_interface.h
+++ b/net/tools/balsa/balsa_visitor_interface.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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 NET_TOOLS_FLIP_SERVER_BALSA_VISITOR_INTERFACE_H_
-#define NET_TOOLS_FLIP_SERVER_BALSA_VISITOR_INTERFACE_H_
+#ifndef NET_TOOLS_BALSA_BALSA_VISITOR_INTERFACE_H_
+#define NET_TOOLS_BALSA_BALSA_VISITOR_INTERFACE_H_
 
 #include <cstddef>
 
@@ -177,5 +177,4 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_BALSA_VISITOR_INTERFACE_H_
-
+#endif  // NET_TOOLS_BALSA_BALSA_VISITOR_INTERFACE_H_
diff --git a/net/tools/flip_server/buffer_interface.h b/net/tools/balsa/buffer_interface.h
similarity index 94%
rename from net/tools/flip_server/buffer_interface.h
rename to net/tools/balsa/buffer_interface.h
index ec061c9..9c01a06 100644
--- a/net/tools/flip_server/buffer_interface.h
+++ b/net/tools/balsa/buffer_interface.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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 NET_TOOLS_FLIP_SERVER_BUFFER_INTERFACE_H__
-#define NET_TOOLS_FLIP_SERVER_BUFFER_INTERFACE_H__
+#ifndef NET_TOOLS_BALSA_BUFFER_INTERFACE_H__
+#define NET_TOOLS_BALSA_BUFFER_INTERFACE_H__
 
 namespace net {
 
@@ -117,5 +117,5 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_BUFFER_INTERFACE__H__
+#endif  // NET_TOOLS_BALSA_BUFFER_INTERFACE__H__
 
diff --git a/net/tools/balsa/http_message_constants.cc b/net/tools/balsa/http_message_constants.cc
new file mode 100644
index 0000000..96a9725
--- /dev/null
+++ b/net/tools/balsa/http_message_constants.cc
@@ -0,0 +1,146 @@
+// 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.
+
+#include "net/tools/balsa/http_message_constants.h"
+
+namespace net {
+
+const char* get_http_status_message(int status_message) {
+  switch (status_message) {
+    case 100:
+      return "Continue";
+    case 101:
+      return "Switching Protocols";
+    case 200:
+      return "OK";
+    case 201:
+      return "Created";
+    case 202:
+      return "Accepted";
+    case 203:
+      return "Non-Authoritative Information";
+    case 204:
+      return "No Content";
+    case 205:
+      return "Reset Content";
+    case 206:
+      return "Partial Content";
+    case 300:
+      return "Multiple Choices";
+    case 301:
+      return "Moved Permanently";
+    case 302:
+      return "Found";
+    case 303:
+      return "See Other";
+    case 304:
+      return "Not Modified";
+    case 305:
+      return "Use Proxy";
+    case 307:
+      return "Temporary Redirect";
+    case 400:
+      return "Bad Request";
+    case 401:
+      return "Unauthorized";
+    case 402:
+      return "Payment Required";
+    case 403:
+      return "Forbidden";
+    case 404:
+      return "Not Found";
+    case 405:
+      return "Method Not Allowed";
+    case 406:
+      return "Not Acceptable";
+    case 407:
+      return "Proxy Authentication Required";
+    case 408:
+      return "Request Time-out";
+    case 409:
+      return "Conflict";
+    case 410:
+      return "Gone";
+    case 411:
+      return "Length Required";
+    case 412:
+      return "Precondition Failed";
+    case 413:
+      return "Request Entity Too Large";
+    case 414:
+      return "Request-URI Too Large";
+    case 415:
+      return "Unsupported Media Type";
+    case 416:
+      return "Requested range not satisfiable";
+    case 417:
+      return "Expectation Failed";
+    case 500:
+      return "Internal Server Error";
+    case 501:
+      return "Not Implemented";
+    case 502:
+      return "Bad Gateway";
+    case 503:
+      return "Service Unavailable";
+    case 504:
+      return "Gateway Time-out";
+    case 505:
+      return "HTTP Version not supported";
+  }
+  return "unknown";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+const int http_status_codes[] = {
+  100,
+  101,
+  200,
+  201,
+  202,
+  203,
+  204,
+  205,
+  206,
+  300,
+  301,
+  302,
+  303,
+  304,
+  305,
+  307,
+  400,
+  401,
+  402,
+  403,
+  404,
+  405,
+  406,
+  407,
+  408,
+  409,
+  410,
+  411,
+  412,
+  413,
+  414,
+  415,
+  416,
+  417,
+  500,
+  501,
+  502,
+  503,
+  504,
+  505
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+const int http_status_code_count = sizeof(http_status_codes) /
+                                   sizeof(http_status_codes[0]);
+
+}  // namespace net
+
diff --git a/net/tools/balsa/http_message_constants.h b/net/tools/balsa/http_message_constants.h
new file mode 100644
index 0000000..16f7aa3
--- /dev/null
+++ b/net/tools/balsa/http_message_constants.h
@@ -0,0 +1,17 @@
+// 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 NET_TOOLS_BALSA_HTTP_MESSAGE_CONSTANTS_H__
+#define NET_TOOLS_BALSA_HTTP_MESSAGE_CONSTANTS_H__
+
+namespace net {
+
+const char* get_http_status_message(int status_message);
+extern const int http_status_codes[];
+extern const int http_status_code_count;
+
+}  // namespace net
+
+#endif  // NET_TOOLS_BALSA_HTTP_MESSAGE_CONSTANTS_H__
+
diff --git a/net/tools/balsa/noop_balsa_visitor.h b/net/tools/balsa/noop_balsa_visitor.h
new file mode 100644
index 0000000..c0136f1
--- /dev/null
+++ b/net/tools/balsa/noop_balsa_visitor.h
@@ -0,0 +1,60 @@
+// 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.
+//
+// Provides empty BalsaVisitorInterface overrides for convenience.
+// Intended to be used as a base class for BalsaVisitorInterface subclasses that
+// only need to override a small number of methods.
+
+#ifndef NET_TOOLS_BALSA_NOOP_BALSA_VISITOR_H_
+#define NET_TOOLS_BALSA_NOOP_BALSA_VISITOR_H_
+
+#include "net/tools/balsa/balsa_visitor_interface.h"
+
+namespace net {
+
+// See file comment above.
+class NoOpBalsaVisitor : public BalsaVisitorInterface {
+ public:
+  NoOpBalsaVisitor() { }
+  virtual ~NoOpBalsaVisitor() { }
+
+  virtual void ProcessBodyInput(const char* input, size_t size) OVERRIDE { }
+  virtual void ProcessBodyData(const char* input, size_t size) OVERRIDE { }
+  virtual void ProcessHeaderInput(const char* input, size_t size) OVERRIDE { }
+  virtual void ProcessTrailerInput(const char* input, size_t size) OVERRIDE { }
+  virtual void ProcessHeaders(const BalsaHeaders& headers) OVERRIDE { }
+
+  virtual void ProcessRequestFirstLine(const char* line_input,
+                                       size_t line_length,
+                                       const char* method_input,
+                                       size_t method_length,
+                                       const char* request_uri_input,
+                                       size_t request_uri_length,
+                                       const char* version_input,
+                                       size_t version_length) OVERRIDE { }
+  virtual void ProcessResponseFirstLine(const char* line_input,
+                                        size_t line_length,
+                                        const char* version_input,
+                                        size_t version_length,
+                                        const char* status_input,
+                                        size_t status_length,
+                                        const char* reason_input,
+                                        size_t reason_length) OVERRIDE { }
+  virtual void ProcessChunkLength(size_t chunk_length) OVERRIDE { }
+  virtual void ProcessChunkExtensions(const char* input, size_t size) OVERRIDE {
+  }
+  virtual void HeaderDone() OVERRIDE { }
+  virtual void MessageDone() OVERRIDE { }
+  virtual void HandleHeaderError(BalsaFrame* framer) OVERRIDE { }
+  virtual void HandleHeaderWarning(BalsaFrame* framer) OVERRIDE { }
+  virtual void HandleChunkingError(BalsaFrame* framer) OVERRIDE { }
+  virtual void HandleBodyError(BalsaFrame* framer) OVERRIDE { }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(NoOpBalsaVisitor);
+};
+
+}  // namespace net
+
+#endif  // NET_TOOLS_BALSA_NOOP_BALSA_VISITOR_H_
diff --git a/net/tools/flip_server/simple_buffer.cc b/net/tools/balsa/simple_buffer.cc
similarity index 97%
rename from net/tools/flip_server/simple_buffer.cc
rename to net/tools/balsa/simple_buffer.cc
index d94153b..5e02a7b 100644
--- a/net/tools/flip_server/simple_buffer.cc
+++ b/net/tools/balsa/simple_buffer.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
 
-#include "net/tools/flip_server/simple_buffer.h"
+#include "net/tools/balsa/simple_buffer.h"
 #include "base/logging.h"
 
 // Some of the following member functions are marked inlined, even though they
diff --git a/net/tools/flip_server/simple_buffer.h b/net/tools/balsa/simple_buffer.h
similarity index 89%
rename from net/tools/flip_server/simple_buffer.h
rename to net/tools/balsa/simple_buffer.h
index 08f7d38..a550617 100644
--- a/net/tools/flip_server/simple_buffer.h
+++ b/net/tools/balsa/simple_buffer.h
@@ -1,14 +1,14 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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 NET_TOOLS_FLIP_SERVER_SIMPLE_BUFFER_H__
-#define NET_TOOLS_FLIP_SERVER_SIMPLE_BUFFER_H__
+#ifndef NET_TOOLS_BALSA_SIMPLE_BUFFER_H__
+#define NET_TOOLS_BALSA_SIMPLE_BUFFER_H__
 
 #include <string>
 
 #include "base/compiler_specific.h"
-#include "net/tools/flip_server/buffer_interface.h"
+#include "net/tools/balsa/buffer_interface.h"
 
 namespace net {
 
@@ -89,4 +89,4 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_SIMPLE_BUFFER_H__
+#endif  // NET_TOOLS_BALSA_SIMPLE_BUFFER_H__
diff --git a/net/tools/flip_server/split.cc b/net/tools/balsa/split.cc
similarity index 93%
rename from net/tools/flip_server/split.cc
rename to net/tools/balsa/split.cc
index 7900513..20be430 100644
--- a/net/tools/flip_server/split.cc
+++ b/net/tools/balsa/split.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
 
-#include "net/tools/flip_server/split.h"
+#include "net/tools/balsa/split.h"
 
 #include <string.h>
 
diff --git a/net/tools/flip_server/split.h b/net/tools/balsa/split.h
similarity index 73%
rename from net/tools/flip_server/split.h
rename to net/tools/balsa/split.h
index aae20b0..6901c2d 100644
--- a/net/tools/flip_server/split.h
+++ b/net/tools/balsa/split.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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 NET_TOOLS_FLIP_SERVER_SPLIT_H_
-#define NET_TOOLS_FLIP_SERVER_SPLIT_H_
+#ifndef NET_TOOLS_BALSA_SPLIT_H_
+#define NET_TOOLS_BALSA_SPLIT_H_
 
 #include <vector>
 #include "base/strings/string_piece.h"
@@ -19,5 +19,5 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_SPLIT_H_
+#endif  // NET_TOOLS_BALSA_SPLIT_H_
 
diff --git a/net/tools/flip_server/string_piece_utils.h b/net/tools/balsa/string_piece_utils.h
similarity index 90%
rename from net/tools/flip_server/string_piece_utils.h
rename to net/tools/balsa/string_piece_utils.h
index 3c46dd9..eb0eaf3 100644
--- a/net/tools/flip_server/string_piece_utils.h
+++ b/net/tools/balsa/string_piece_utils.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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 NET_TOOLS_FLIP_SERVER_STRING_PIECE_UTILS_H_
-#define NET_TOOLS_FLIP_SERVER_STRING_PIECE_UTILS_H_
+#ifndef NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_
+#define NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_
 
 #include <ctype.h>
 
@@ -79,5 +79,5 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_STRING_PIECE_UTILS_H_
+#endif  // NET_TOOLS_BALSA_STRING_PIECE_UTILS_H_
 
diff --git a/net/tools/flip_server/epoll_server.cc b/net/tools/epoll_server/epoll_server.cc
similarity index 99%
rename from net/tools/flip_server/epoll_server.cc
rename to net/tools/epoll_server/epoll_server.cc
index 0e09a6d..a382dba 100644
--- a/net/tools/flip_server/epoll_server.cc
+++ b/net/tools/epoll_server/epoll_server.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
 
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 
 #include <unistd.h>  // For read, pipe, close and write.
 #include <stdlib.h>  // for abort
diff --git a/net/tools/flip_server/epoll_server.h b/net/tools/epoll_server/epoll_server.h
similarity index 99%
rename from net/tools/flip_server/epoll_server.h
rename to net/tools/epoll_server/epoll_server.h
index 2fb7c62..8822450 100644
--- a/net/tools/flip_server/epoll_server.h
+++ b/net/tools/epoll_server/epoll_server.h
@@ -1,16 +1,16 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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 NET_TOOLS_FLIP_SERVER_EPOLL_SERVER_H_
-#define NET_TOOLS_FLIP_SERVER_EPOLL_SERVER_H_
+#ifndef NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_
+#define NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_
 
 #include <fcntl.h>
 #include <sys/queue.h>
 #include <map>
+#include <set>
 #include <string>
 #include <utility>
-#include <set>
 #include <vector>
 
 // #define EPOLL_SERVER_EVENT_TRACING 1
@@ -1050,5 +1050,4 @@
 
 }  // namespace net
 
-#endif  // NET_TOOLS_FLIP_SERVER_EPOLL_SERVER_H_
-
+#endif  // NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_
diff --git a/net/tools/flip_server/acceptor_thread.h b/net/tools/flip_server/acceptor_thread.h
index f967fac..7c758d9 100644
--- a/net/tools/flip_server/acceptor_thread.h
+++ b/net/tools/flip_server/acceptor_thread.h
@@ -11,7 +11,7 @@
 
 #include "base/compiler_specific.h"
 #include "base/threading/simple_thread.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/flip_server/sm_interface.h"
 #include "openssl/ssl.h"
 
diff --git a/net/tools/flip_server/flip_in_mem_edsm_server.cc b/net/tools/flip_server/flip_in_mem_edsm_server.cc
index ce7ffb8..79f3e5b 100644
--- a/net/tools/flip_server/flip_in_mem_edsm_server.cc
+++ b/net/tools/flip_server/flip_in_mem_edsm_server.cc
@@ -15,6 +15,7 @@
 #include "base/logging.h"
 #include "base/synchronization/lock.h"
 #include "base/timer/timer.h"
+#include "net/tools/balsa/split.h"
 #include "net/tools/flip_server/acceptor_thread.h"
 #include "net/tools/flip_server/constants.h"
 #include "net/tools/flip_server/flip_config.h"
@@ -22,7 +23,6 @@
 #include "net/tools/flip_server/sm_connection.h"
 #include "net/tools/flip_server/sm_interface.h"
 #include "net/tools/flip_server/spdy_interface.h"
-#include "net/tools/flip_server/split.h"
 #include "net/tools/flip_server/streamer_interface.h"
 
 using std::cout;
@@ -421,4 +421,3 @@
   close(pidfile_fd);
   return 0;
 }
-
diff --git a/net/tools/flip_server/http_interface.cc b/net/tools/flip_server/http_interface.cc
index 916ba51..78c42cc 100644
--- a/net/tools/flip_server/http_interface.cc
+++ b/net/tools/flip_server/http_interface.cc
@@ -4,8 +4,8 @@
 
 #include "net/tools/flip_server/http_interface.h"
 
+#include "net/tools/balsa/balsa_frame.h"
 #include "net/tools/dump_cache/url_utilities.h"
-#include "net/tools/flip_server/balsa_frame.h"
 #include "net/tools/flip_server/flip_config.h"
 #include "net/tools/flip_server/sm_connection.h"
 #include "net/tools/flip_server/spdy_util.h"
diff --git a/net/tools/flip_server/http_interface.h b/net/tools/flip_server/http_interface.h
index 18e616d..867e342 100644
--- a/net/tools/flip_server/http_interface.h
+++ b/net/tools/flip_server/http_interface.h
@@ -8,8 +8,8 @@
 #include <string>
 
 #include "base/compiler_specific.h"
-#include "net/tools/flip_server/balsa_headers.h"
-#include "net/tools/flip_server/balsa_visitor_interface.h"
+#include "net/tools/balsa/balsa_headers.h"
+#include "net/tools/balsa/balsa_visitor_interface.h"
 #include "net/tools/flip_server/output_ordering.h"
 #include "net/tools/flip_server/sm_connection.h"
 #include "net/tools/flip_server/sm_interface.h"
diff --git a/net/tools/flip_server/http_interface_test.cc b/net/tools/flip_server/http_interface_test.cc
index ba9b3aa..c6e3c64 100644
--- a/net/tools/flip_server/http_interface_test.cc
+++ b/net/tools/flip_server/http_interface_test.cc
@@ -9,9 +9,9 @@
 #include "base/memory/scoped_ptr.h"
 #include "base/stl_util.h"
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_enums.h"
-#include "net/tools/flip_server/balsa_frame.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_enums.h"
+#include "net/tools/balsa/balsa_frame.h"
+#include "net/tools/balsa/balsa_headers.h"
 #include "net/tools/flip_server/flip_config.h"
 #include "net/tools/flip_server/flip_test_utils.h"
 #include "net/tools/flip_server/mem_cache.h"
diff --git a/net/tools/flip_server/http_message_constants.h b/net/tools/flip_server/http_message_constants.h
deleted file mode 100644
index de700cc..0000000
--- a/net/tools/flip_server/http_message_constants.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2009 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 NET_TOOLS_FLIP_SERVER_HTTP_MESSAGE_CONSTANTS_H__
-#define NET_TOOLS_FLIP_SERVER_HTTP_MESSAGE_CONSTANTS_H__
-
-namespace net {
-
-const char* get_http_status_message(int status_message);
-extern const int http_status_codes[];
-extern const int http_status_code_count;
-
-}  // namespace net
-
-#endif  // NET_TOOLS_FLIP_SERVER_HTTP_MESSAGE_CONSTANTS_H__
-
diff --git a/net/tools/flip_server/mem_cache.cc b/net/tools/flip_server/mem_cache.cc
index d1e0e58..42d9343 100644
--- a/net/tools/flip_server/mem_cache.cc
+++ b/net/tools/flip_server/mem_cache.cc
@@ -17,10 +17,10 @@
 #include <string>
 
 #include "base/strings/string_util.h"
+#include "net/tools/balsa/balsa_frame.h"
+#include "net/tools/balsa/balsa_headers.h"
 #include "net/tools/dump_cache/url_to_filename_encoder.h"
 #include "net/tools/dump_cache/url_utilities.h"
-#include "net/tools/flip_server/balsa_frame.h"
-#include "net/tools/flip_server/balsa_headers.h"
 
 namespace {
 // The directory where cache locates);
diff --git a/net/tools/flip_server/mem_cache.h b/net/tools/flip_server/mem_cache.h
index 300c84a..b059f02 100644
--- a/net/tools/flip_server/mem_cache.h
+++ b/net/tools/flip_server/mem_cache.h
@@ -10,8 +10,8 @@
 
 #include "base/compiler_specific.h"
 #include "base/memory/scoped_ptr.h"
-#include "net/tools/flip_server/balsa_headers.h"
-#include "net/tools/flip_server/balsa_visitor_interface.h"
+#include "net/tools/balsa/balsa_headers.h"
+#include "net/tools/balsa/balsa_visitor_interface.h"
 #include "net/tools/flip_server/constants.h"
 
 namespace net {
diff --git a/net/tools/flip_server/mem_cache_test.cc b/net/tools/flip_server/mem_cache_test.cc
index d5601ac..59bc485 100644
--- a/net/tools/flip_server/mem_cache_test.cc
+++ b/net/tools/flip_server/mem_cache_test.cc
@@ -4,7 +4,7 @@
 
 #include "net/tools/flip_server/mem_cache.h"
 
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace net {
diff --git a/net/tools/flip_server/output_ordering.h b/net/tools/flip_server/output_ordering.h
index 922d03f..c1441f0 100644
--- a/net/tools/flip_server/output_ordering.h
+++ b/net/tools/flip_server/output_ordering.h
@@ -11,8 +11,8 @@
 
 #include "base/basictypes.h"
 #include "base/compiler_specific.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/flip_server/constants.h"
-#include "net/tools/flip_server/epoll_server.h"
 #include "net/tools/flip_server/mem_cache.h"
 
 namespace net {
diff --git a/net/tools/flip_server/ring_buffer.h b/net/tools/flip_server/ring_buffer.h
index 03cbde7..ef660c3 100644
--- a/net/tools/flip_server/ring_buffer.h
+++ b/net/tools/flip_server/ring_buffer.h
@@ -7,7 +7,7 @@
 
 #include "base/compiler_specific.h"
 #include "base/memory/scoped_ptr.h"
-#include "net/tools/flip_server/buffer_interface.h"
+#include "net/tools/balsa/buffer_interface.h"
 
 namespace net {
 
diff --git a/net/tools/flip_server/sm_connection.h b/net/tools/flip_server/sm_connection.h
index 3e21772..a79dca9 100644
--- a/net/tools/flip_server/sm_connection.h
+++ b/net/tools/flip_server/sm_connection.h
@@ -12,8 +12,8 @@
 #include <string>
 
 #include "base/compiler_specific.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/flip_server/create_listener.h"
-#include "net/tools/flip_server/epoll_server.h"
 #include "net/tools/flip_server/mem_cache.h"
 #include "net/tools/flip_server/ring_buffer.h"
 #include "net/tools/flip_server/sm_interface.h"
diff --git a/net/tools/flip_server/sm_interface.h b/net/tools/flip_server/sm_interface.h
index 5bc942f..28e5bc6 100644
--- a/net/tools/flip_server/sm_interface.h
+++ b/net/tools/flip_server/sm_interface.h
@@ -9,7 +9,7 @@
 
 #include <string>
 
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 
 namespace net {
 
diff --git a/net/tools/flip_server/spdy_interface.h b/net/tools/flip_server/spdy_interface.h
index 3ce1f3b..3b2e513 100644
--- a/net/tools/flip_server/spdy_interface.h
+++ b/net/tools/flip_server/spdy_interface.h
@@ -12,8 +12,8 @@
 #include "base/compiler_specific.h"
 #include "net/spdy/buffered_spdy_framer.h"
 #include "net/spdy/spdy_protocol.h"
-#include "net/tools/flip_server/balsa_headers.h"
-#include "net/tools/flip_server/balsa_visitor_interface.h"
+#include "net/tools/balsa/balsa_headers.h"
+#include "net/tools/balsa/balsa_visitor_interface.h"
 #include "net/tools/flip_server/output_ordering.h"
 #include "net/tools/flip_server/sm_connection.h"
 #include "net/tools/flip_server/sm_interface.h"
diff --git a/net/tools/flip_server/spdy_interface_test.cc b/net/tools/flip_server/spdy_interface_test.cc
index 7a1c6e9..4dbfea8 100644
--- a/net/tools/flip_server/spdy_interface_test.cc
+++ b/net/tools/flip_server/spdy_interface_test.cc
@@ -9,8 +9,8 @@
 #include "base/memory/scoped_ptr.h"
 #include "base/strings/string_piece.h"
 #include "net/spdy/buffered_spdy_framer.h"
-#include "net/tools/flip_server/balsa_enums.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_enums.h"
+#include "net/tools/balsa/balsa_headers.h"
 #include "net/tools/flip_server/flip_config.h"
 #include "net/tools/flip_server/flip_test_utils.h"
 #include "net/tools/flip_server/mem_cache.h"
diff --git a/net/tools/flip_server/streamer_interface.cc b/net/tools/flip_server/streamer_interface.cc
index b1612e7..8c2e0e7 100644
--- a/net/tools/flip_server/streamer_interface.cc
+++ b/net/tools/flip_server/streamer_interface.cc
@@ -6,7 +6,7 @@
 
 #include <string>
 
-#include "net/tools/flip_server/balsa_frame.h"
+#include "net/tools/balsa/balsa_frame.h"
 #include "net/tools/flip_server/constants.h"
 #include "net/tools/flip_server/flip_config.h"
 #include "net/tools/flip_server/sm_connection.h"
diff --git a/net/tools/flip_server/streamer_interface.h b/net/tools/flip_server/streamer_interface.h
index 4f09b45..efaee6b 100644
--- a/net/tools/flip_server/streamer_interface.h
+++ b/net/tools/flip_server/streamer_interface.h
@@ -8,8 +8,8 @@
 #include <string>
 
 #include "base/compiler_specific.h"
-#include "net/tools/flip_server/balsa_headers.h"
-#include "net/tools/flip_server/balsa_visitor_interface.h"
+#include "net/tools/balsa/balsa_headers.h"
+#include "net/tools/balsa/balsa_visitor_interface.h"
 #include "net/tools/flip_server/sm_interface.h"
 
 namespace net {
diff --git a/net/tools/net_watcher/net_watcher.cc b/net/tools/net_watcher/net_watcher.cc
index 0a8b4df..67eb124 100644
--- a/net/tools/net_watcher/net_watcher.cc
+++ b/net/tools/net_watcher/net_watcher.cc
@@ -21,7 +21,7 @@
 #include "net/proxy/proxy_config_service.h"
 #include "net/proxy/proxy_service.h"
 
-#if (defined(OS_LINUX) || defined(OS_OPENBSD)) && !defined(OS_CHROMEOS)
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
 #include <glib-object.h>
 #endif
 
@@ -131,26 +131,16 @@
 #if defined(OS_MACOSX)
   base::mac::ScopedNSAutoreleasePool pool;
 #endif
-#if (defined(OS_LINUX) || defined(OS_OPENBSD)) && !defined(OS_CHROMEOS)
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
+  // g_type_init will be deprecated in 2.36. 2.35 is the development
+  // version for 2.36, hence do not call g_type_init starting 2.35.
+  // http://developer.gnome.org/gobject/unstable/gobject-Type-Information.html#g-type-init
+#if !GLIB_CHECK_VERSION(2, 35, 0)
   // Needed so ProxyConfigServiceLinux can use gconf.
   // Normally handled by BrowserMainLoop::InitializeToolkit().
-  // From glib version 2.36 onwards, g_type_init is implicitly called and it is
-  // deprecated.
-  // TODO(yael) Simplify this once Ubuntu 10.04 is no longer supported.
-#if defined(G_GNUC_BEGIN_IGNORE_DEPRECATIONS) && \
-    defined(G_GNUC_END_IGNORE_DEPRECATIONS)
-#define USE_GLIB_DEPRECATIONS_MACROS
-#endif
-
-#if defined(USE_GLIB_DEPRECATIONS_MACROS)
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-#endif
   g_type_init();
-#if defined(USE_GLIB_DEPRECATIONS_MACROS)
-G_GNUC_END_IGNORE_DEPRECATIONS
 #endif
-#undef USE_GLIB_DEPRECATIONS_MACROS
-#endif  // (defined(OS_LINUX) || defined(OS_OPENBSD)) && !defined(OS_CHROMEOS)
+#endif  // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
   base::AtExitManager exit_manager;
   CommandLine::Init(argc, argv);
   logging::LoggingSettings settings;
diff --git a/net/tools/quic/end_to_end_test.cc b/net/tools/quic/end_to_end_test.cc
index e47d1d5..f453c60 100644
--- a/net/tools/quic/end_to_end_test.cc
+++ b/net/tools/quic/end_to_end_test.cc
@@ -25,6 +25,7 @@
 #include "net/tools/quic/test_tools/http_message_test_utils.h"
 #include "net/tools/quic/test_tools/quic_client_peer.h"
 #include "net/tools/quic/test_tools/quic_epoll_connection_helper_peer.h"
+#include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h"
 #include "net/tools/quic/test_tools/quic_test_client.h"
 #include "net/tools/quic/test_tools/server_thread.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -58,11 +59,6 @@
 }
 
 class EndToEndTest : public ::testing::TestWithParam<QuicVersion> {
- public:
-  static void SetUpTestCase() {
-    QuicInMemoryCache::GetInstance()->ResetForTests();
-  }
-
  protected:
   EndToEndTest()
       : server_hostname_("example.com"),
@@ -76,6 +72,7 @@
     client_config_.SetDefaults();
     server_config_.SetDefaults();
 
+    QuicInMemoryCachePeer::ResetForTests();
     AddToCache("GET", kLargeRequest, "HTTP/1.1", "200", "OK", kFooResponseBody);
     AddToCache("GET", "https://www.google.com/foo",
                "HTTP/1.1", "200", "OK", kFooResponseBody);
@@ -84,6 +81,10 @@
     version_ = GetParam();
   }
 
+  virtual ~EndToEndTest() {
+    QuicInMemoryCachePeer::ResetForTests();
+  }
+
   virtual QuicTestClient* CreateQuicClient() {
     QuicTestClient* client = new QuicTestClient(server_address_,
                                                 server_hostname_,
@@ -131,7 +132,7 @@
                   StringPiece response_code,
                   StringPiece response_detail,
                   StringPiece body) {
-    QuicInMemoryCache::GetInstance()->AddOrVerifyResponse(
+    QuicInMemoryCache::GetInstance()->AddSimpleResponse(
         method, path, version, response_code, response_detail, body);
   }
 
@@ -152,12 +153,6 @@
                         ::testing::ValuesIn(kSupportedQuicVersions));
 
 TEST_P(EndToEndTest, SimpleRequestResponse) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
 
   EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
@@ -167,12 +162,6 @@
 // TODO(rch): figure out how to detect missing v6 supprt (like on the linux
 // try bots) and selectively disable this test.
 TEST_P(EndToEndTest, DISABLED_SimpleRequestResponsev6) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   IPAddressNumber ip;
   CHECK(net::ParseIPLiteralToNumber("::1", &ip));
   server_address_ = IPEndPoint(ip, server_address_.port());
@@ -183,12 +172,6 @@
 }
 
 TEST_P(EndToEndTest, SeparateFinPacket) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
 
   HTTPMessage request(HttpConstants::HTTP_1_1,
@@ -213,12 +196,6 @@
 }
 
 TEST_P(EndToEndTest, MultipleRequestResponse) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
 
   EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
@@ -228,12 +205,6 @@
 }
 
 TEST_P(EndToEndTest, MultipleClients) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
   scoped_ptr<QuicTestClient> client2(CreateQuicClient());
 
@@ -257,12 +228,6 @@
 }
 
 TEST_P(EndToEndTest, RequestOverMultiplePackets) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
   // Set things up so we have a small payload, to guarantee fragmentation.
   // A congestion feedback frame can't be split into multiple packets, make sure
@@ -278,7 +243,8 @@
           GetParam(), kStreamId, kStreamOffset, true) + kStreamDataLength;
   size_t min_payload_size =
       std::max(kCongestionFeedbackFrameSize, stream_payload_size);
-  size_t ciphertext_size = NullEncrypter().GetCiphertextSize(min_payload_size);
+  size_t ciphertext_size =
+      NullEncrypter(GetParam()).GetCiphertextSize(min_payload_size);
   // TODO(satyashekhar): Fix this when versioning is implemented.
   client_->options()->max_packet_length =
       GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
@@ -292,12 +258,6 @@
 }
 
 TEST_P(EndToEndTest, MultipleFramesRandomOrder) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
   // Set things up so we have a small payload, to guarantee fragmentation.
   // A congestion feedback frame can't be split into multiple packets, make sure
@@ -313,7 +273,8 @@
           GetParam(), kStreamId, kStreamOffset, true) + kStreamDataLength;
   size_t min_payload_size =
       std::max(kCongestionFeedbackFrameSize, stream_payload_size);
-  size_t ciphertext_size = NullEncrypter().GetCiphertextSize(min_payload_size);
+  size_t ciphertext_size =
+      NullEncrypter(GetParam()).GetCiphertextSize(min_payload_size);
   // TODO(satyashekhar): Fix this when versioning is implemented.
   client_->options()->max_packet_length =
       GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion,
@@ -328,12 +289,6 @@
 }
 
 TEST_P(EndToEndTest, PostMissingBytes) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
 
   // Add a content length header with no body.
@@ -350,12 +305,6 @@
 }
 
 TEST_P(EndToEndTest, LargePostNoPacketLoss) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
 
   client_->client()->WaitForCryptoHandshakeConfirmed();
@@ -372,12 +321,6 @@
 }
 
 TEST_P(EndToEndTest, LargePostWithPacketLoss) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   // Connect with lower fake packet loss than we'd like to test.  Until
   // b/10126687 is fixed, losing handshake packets is pretty brutal.
   // FLAGS_fake_packet_loss_percentage = 5;
@@ -442,16 +385,6 @@
   ASSERT_TRUE(Initialize());
   client_->options()->max_packets_per_fec_group = 6;
 
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
-  // FLAGS_fake_packet_loss_percentage = 30;
-  ASSERT_TRUE(Initialize());
-  client_->options()->max_packets_per_fec_group = 6;
-
   string body;
   GenerateBody(&body, 10240);
 
@@ -480,12 +413,6 @@
 }*/
 
 TEST_P(EndToEndTest, InvalidStream) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
 
   string body;
@@ -505,12 +432,6 @@
 
 // TODO(rch): this test seems to cause net_unittests timeouts :|
 TEST_P(EndToEndTest, DISABLED_MultipleTermination) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
 
   HTTPMessage request(HttpConstants::HTTP_1_1,
@@ -576,12 +497,6 @@
 }
 
 TEST_P(EndToEndTest, ResetConnection) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
 
   EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
@@ -621,14 +536,13 @@
     self_address_ = IPEndPoint(ip, 0);
   }
 
-  virtual int WritePacket(const char* buffer, size_t buf_len,
-                          const IPAddressNumber& real_self_address,
-                          const IPEndPoint& peer_address,
-                          QuicBlockedWriterInterface* blocked_writer,
-                          int* error) OVERRIDE {
+  virtual WriteResult WritePacket(
+      const char* buffer, size_t buf_len,
+      const IPAddressNumber& real_self_address,
+      const IPEndPoint& peer_address,
+      QuicBlockedWriterInterface* blocked_writer) OVERRIDE {
     return QuicSocketUtils::WritePacket(fd_, buffer, buf_len,
-                                        self_address_.address(), peer_address,
-                                        error);
+                                        self_address_.address(), peer_address);
   }
 
   IPEndPoint self_address_;
@@ -636,12 +550,6 @@
 };
 
 TEST_P(EndToEndTest, ConnectionMigration) {
-  // TODO(rtenneti): Delete this when NSS is supported.
-  if (!Aes128Gcm12Encrypter::IsSupported()) {
-    LOG(INFO) << "AES GCM not supported. Test skipped.";
-    return;
-  }
-
   ASSERT_TRUE(Initialize());
 
   EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc
index 86fa6c4..68cdf00 100644
--- a/net/tools/quic/quic_client.cc
+++ b/net/tools/quic/quic_client.cc
@@ -16,7 +16,7 @@
 #include "net/quic/quic_connection.h"
 #include "net/quic/quic_data_reader.h"
 #include "net/quic/quic_protocol.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 #include "net/tools/quic/quic_epoll_connection_helper.h"
 #include "net/tools/quic/quic_reliable_client_stream.h"
 #include "net/tools/quic/quic_socket_utils.h"
@@ -32,7 +32,8 @@
 
 QuicClient::QuicClient(IPEndPoint server_address,
                        const string& server_hostname,
-                       const QuicVersion version)
+                       const QuicVersion version,
+                       bool print_response)
     : server_address_(server_address),
       server_hostname_(server_hostname),
       local_port_(0),
@@ -40,7 +41,8 @@
       initialized_(false),
       packets_dropped_(0),
       overflow_supported_(false),
-      version_(version) {
+      version_(version),
+      print_response_(print_response) {
   config_.SetDefaults();
 }
 
@@ -56,7 +58,8 @@
       initialized_(false),
       packets_dropped_(0),
       overflow_supported_(false),
-      version_(version) {
+      version_(version),
+      print_response_(false) {
 }
 
 QuicClient::~QuicClient() {
@@ -178,10 +181,12 @@
 
 void QuicClient::SendRequestsAndWaitForResponse(
     const CommandLine::StringVector& args) {
-  for (uint32_t i = 0; i < args.size(); i++) {
+  for (size_t i = 0; i < args.size(); i++) {
     BalsaHeaders headers;
     headers.SetRequestFirstlineFromStringPieces("GET", args[i], "HTTP/1.1");
-    CreateReliableClientStream()->SendRequest(headers, "", true);
+    QuicReliableClientStream* stream = CreateReliableClientStream();
+    stream->SendRequest(headers, "", true);
+    stream->set_visitor(this);
   }
 
   while (WaitForEvents()) { }
@@ -233,6 +238,24 @@
   }
 }
 
+void QuicClient::OnClose(ReliableQuicStream* stream) {
+  if (!print_response_) {
+    return;
+  }
+
+  QuicReliableClientStream* client_stream =
+      static_cast<QuicReliableClientStream*>(stream);
+  const BalsaHeaders& headers = client_stream->headers();
+  printf("%s\n", headers.first_line().as_string().c_str());
+  for (BalsaHeaders::const_header_lines_iterator i =
+           headers.header_lines_begin();
+       i != headers.header_lines_end(); ++i) {
+    printf("%s: %s\n", i->first.as_string().c_str(),
+           i->second.as_string().c_str());
+  }
+  printf("%s\n", client_stream->data().c_str());
+}
+
 QuicPacketCreator::Options* QuicClient::options() {
   if (session() == NULL) {
     return NULL;
diff --git a/net/tools/quic/quic_client.h b/net/tools/quic/quic_client.h
index 5e89601..8826815 100644
--- a/net/tools/quic/quic_client.h
+++ b/net/tools/quic/quic_client.h
@@ -18,7 +18,7 @@
 #include "net/quic/quic_config.h"
 #include "net/quic/quic_framer.h"
 #include "net/quic/quic_packet_creator.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_client_session.h"
 #include "net/tools/quic/quic_reliable_client_stream.h"
 
@@ -34,10 +34,13 @@
 class QuicClientPeer;
 }  // namespace test
 
-class QuicClient : public EpollCallbackInterface {
+class QuicClient : public EpollCallbackInterface,
+                   public ReliableQuicStream::Visitor {
  public:
-  QuicClient(IPEndPoint server_address, const std::string& server_hostname,
-             const QuicVersion version);
+  QuicClient(IPEndPoint server_address,
+             const string& server_hostname,
+             const QuicVersion version,
+             bool print_response);
   QuicClient(IPEndPoint server_address,
              const std::string& server_hostname,
              const QuicConfig& config,
@@ -96,6 +99,9 @@
   virtual void OnUnregistration(int fd, bool replaced) OVERRIDE {}
   virtual void OnShutdown(EpollServer* eps, int fd) OVERRIDE {}
 
+  // ReliableQuicStream::Visitor
+  virtual void OnClose(ReliableQuicStream* stream) OVERRIDE;
+
   QuicPacketCreator::Options* options();
 
   QuicClientSession* session() { return session_.get(); }
@@ -190,6 +196,10 @@
   // Which QUIC version does this client talk?
   QuicVersion version_;
 
+  // If true, then the contents of each response will be printed to stdout
+  // when the stream is closed (in OnClose).
+  bool print_response_;
+
   DISALLOW_COPY_AND_ASSIGN(QuicClient);
 };
 
diff --git a/net/tools/quic/quic_client_bin.cc b/net/tools/quic/quic_client_bin.cc
index e13bea5..5591b87 100644
--- a/net/tools/quic/quic_client_bin.cc
+++ b/net/tools/quic/quic_client_bin.cc
@@ -2,11 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// A binary wrapper for QuicClient.  Connects to --hostname or --address on
-// --port and requests URLs specified on the command line.
+// A binary wrapper for QuicClient.  Connects to --hostname via --address
+// on --port and requests URLs specified on the command line.
 //
 // For example:
-//  quic_client --port=6122 /index.html /favicon.ico
+//  quic_client --address=127.0.0.1 --port=6122 --hostname=www.google.com
+//      http://www.google.com/index.html http://www.google.com/favicon.ico
+
+#include <iostream>
 
 #include "base/at_exit.h"
 #include "base/command_line.h"
@@ -23,6 +26,18 @@
 int main(int argc, char *argv[]) {
   CommandLine::Init(argc, argv);
   CommandLine* line = CommandLine::ForCurrentProcess();
+  if (line->HasSwitch("h") || line->HasSwitch("help")) {
+    const char* help_str =
+        "Usage: quic_client [options]\n"
+        "\n"
+        "Options:\n"
+        "-h, --help                  show this help message and exit\n"
+        "--port=<port>               specify the port to connect to\n"
+        "--address=<address>         specify the IP address to connect to\n"
+        "--host=<host>               specify the SNI hostname to use\n";
+    std::cout << help_str;
+    exit(0);
+  }
   if (line->HasSwitch("port")) {
     int port;
     if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) {
@@ -44,8 +59,8 @@
   net::IPAddressNumber addr;
   CHECK(net::ParseIPLiteralToNumber(FLAGS_address, &addr));
   // TODO(rjshade): Set version on command line.
-  net::tools::QuicClient client(
-      net::IPEndPoint(addr, FLAGS_port), FLAGS_hostname, net::QuicVersionMax());
+  net::tools::QuicClient client(net::IPEndPoint(addr, FLAGS_port),
+                                FLAGS_hostname, net::QuicVersionMax(), true);
 
   client.Initialize();
 
diff --git a/net/tools/quic/quic_dispatcher.cc b/net/tools/quic/quic_dispatcher.cc
index 8550ef0..b22b9dc 100644
--- a/net/tools/quic/quic_dispatcher.cc
+++ b/net/tools/quic/quic_dispatcher.cc
@@ -53,25 +53,22 @@
   STLDeleteElements(&closed_session_list_);
 }
 
-int QuicDispatcher::WritePacket(const char* buffer, size_t buf_len,
-                                const IPAddressNumber& self_address,
-                                const IPEndPoint& peer_address,
-                                QuicBlockedWriterInterface* writer,
-                                int* error) {
+WriteResult  QuicDispatcher::WritePacket(const char* buffer, size_t buf_len,
+                                         const IPAddressNumber& self_address,
+                                         const IPEndPoint& peer_address,
+                                         QuicBlockedWriterInterface* writer) {
   if (write_blocked_) {
     write_blocked_list_.insert(make_pair(writer, true));
-    *error = EAGAIN;
-    return -1;
+    return WriteResult(WRITE_STATUS_BLOCKED, EAGAIN);
   }
 
-  int rc = QuicSocketUtils::WritePacket(fd_, buffer, buf_len,
-                                        self_address, peer_address,
-                                        error);
-  if (rc == -1 && (*error == EWOULDBLOCK || *error == EAGAIN)) {
+  WriteResult result = QuicSocketUtils::WritePacket(fd_, buffer, buf_len,
+                                                    self_address, peer_address);
+  if (result.status == WRITE_STATUS_BLOCKED) {
     write_blocked_list_.insert(make_pair(writer, true));
     write_blocked_ = true;
   }
-  return rc;
+  return result;
 }
 
 void QuicDispatcher::ProcessPacket(const IPEndPoint& server_address,
diff --git a/net/tools/quic/quic_dispatcher.h b/net/tools/quic/quic_dispatcher.h
index aea76cb..584965c 100644
--- a/net/tools/quic/quic_dispatcher.h
+++ b/net/tools/quic/quic_dispatcher.h
@@ -15,7 +15,7 @@
 #include "net/base/linked_hash_map.h"
 #include "net/quic/quic_blocked_writer_interface.h"
 #include "net/quic/quic_protocol.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_packet_writer.h"
 #include "net/tools/quic/quic_server_session.h"
 #include "net/tools/quic/quic_time_wait_list_manager.h"
@@ -60,11 +60,11 @@
   virtual ~QuicDispatcher();
 
   // QuicPacketWriter
-  virtual int WritePacket(const char* buffer, size_t buf_len,
-                          const IPAddressNumber& self_address,
-                          const IPEndPoint& peer_address,
-                          QuicBlockedWriterInterface* writer,
-                          int* error) OVERRIDE;
+  virtual WriteResult WritePacket(
+      const char* buffer, size_t buf_len,
+      const IPAddressNumber& self_address,
+      const IPEndPoint& peer_address,
+      QuicBlockedWriterInterface* writer) OVERRIDE;
 
   virtual void ProcessPacket(const IPEndPoint& server_address,
                              const IPEndPoint& client_address,
diff --git a/net/tools/quic/quic_dispatcher_test.cc b/net/tools/quic/quic_dispatcher_test.cc
index 2e2c309..2f105e1 100644
--- a/net/tools/quic/quic_dispatcher_test.cc
+++ b/net/tools/quic/quic_dispatcher_test.cc
@@ -12,7 +12,7 @@
 #include "net/quic/crypto/quic_random.h"
 #include "net/quic/quic_crypto_stream.h"
 #include "net/quic/test_tools/quic_test_utils.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_time_wait_list_manager.h"
 #include "net/tools/quic/test_tools/quic_test_utils.h"
 #include "testing/gmock/include/gmock/gmock.h"
diff --git a/net/tools/quic/quic_epoll_clock.cc b/net/tools/quic/quic_epoll_clock.cc
index 2a3abf1..450afb8 100644
--- a/net/tools/quic/quic_epoll_clock.cc
+++ b/net/tools/quic/quic_epoll_clock.cc
@@ -4,7 +4,7 @@
 
 #include "net/tools/quic/quic_epoll_clock.h"
 
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 
 namespace net {
 namespace tools {
diff --git a/net/tools/quic/quic_epoll_connection_helper.cc b/net/tools/quic/quic_epoll_connection_helper.cc
index 4db1d4c..b7158db 100644
--- a/net/tools/quic/quic_epoll_connection_helper.cc
+++ b/net/tools/quic/quic_epoll_connection_helper.cc
@@ -11,7 +11,7 @@
 #include "base/stl_util.h"
 #include "net/base/ip_endpoint.h"
 #include "net/quic/crypto/quic_random.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_socket_utils.h"
 
 namespace net {
@@ -98,13 +98,11 @@
   return random_generator_;
 }
 
-int QuicEpollConnectionHelper::WritePacketToWire(
-    const QuicEncryptedPacket& packet,
-    int* error) {
+WriteResult QuicEpollConnectionHelper::WritePacketToWire(
+    const QuicEncryptedPacket& packet) {
   if (connection_->ShouldSimulateLostPacket()) {
     DLOG(INFO) << "Dropping packet due to fake packet loss.";
-    *error = 0;
-    return packet.length();
+    return WriteResult(WRITE_STATUS_OK, packet.length());
   }
 
   // If we have a writer, delgate the write to it.
@@ -112,14 +110,12 @@
     return writer_->WritePacket(packet.data(), packet.length(),
                                 connection_->self_address().address(),
                                 connection_->peer_address(),
-                                connection_,
-                                error);
+                                connection_);
   } else {
     return QuicSocketUtils::WritePacket(
         fd_, packet.data(), packet.length(),
         connection_->self_address().address(),
-        connection_->peer_address(),
-        error);
+        connection_->peer_address());
   }
 }
 
@@ -127,10 +123,6 @@
   return false;
 }
 
-bool QuicEpollConnectionHelper::IsWriteBlocked(int error) {
-  return error == EAGAIN || error == EWOULDBLOCK;
-}
-
 QuicAlarm* QuicEpollConnectionHelper::CreateAlarm(
     QuicAlarm::Delegate* delegate) {
   return new QuicEpollAlarm(epoll_server_, delegate);
diff --git a/net/tools/quic/quic_epoll_connection_helper.h b/net/tools/quic/quic_epoll_connection_helper.h
index 5bd526f..f0795ad 100644
--- a/net/tools/quic/quic_epoll_connection_helper.h
+++ b/net/tools/quic/quic_epoll_connection_helper.h
@@ -43,10 +43,9 @@
   virtual void SetConnection(QuicConnection* connection) OVERRIDE;
   virtual const QuicClock* GetClock() const OVERRIDE;
   virtual QuicRandom* GetRandomGenerator() OVERRIDE;
-  virtual int WritePacketToWire(const QuicEncryptedPacket& packet,
-                                int* error) OVERRIDE;
+  virtual WriteResult WritePacketToWire(
+      const QuicEncryptedPacket& packet) OVERRIDE;
   virtual bool IsWriteBlockedDataBuffered() OVERRIDE;
-  virtual bool IsWriteBlocked(int error) OVERRIDE;
   virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) OVERRIDE;
 
   EpollServer* epoll_server() { return epoll_server_; }
diff --git a/net/tools/quic/quic_epoll_connection_helper_test.cc b/net/tools/quic/quic_epoll_connection_helper_test.cc
index a61813c..0e5cd48 100644
--- a/net/tools/quic/quic_epoll_connection_helper_test.cc
+++ b/net/tools/quic/quic_epoll_connection_helper_test.cc
@@ -30,7 +30,7 @@
 namespace test {
 namespace {
 
-const char data1[] = "foo";
+const char kData[] = "foo";
 const bool kFromPeer = true;
 
 class TestConnectionHelper : public QuicEpollConnectionHelper {
@@ -39,15 +39,14 @@
       : QuicEpollConnectionHelper(fd, eps) {
   }
 
-  virtual int WritePacketToWire(const QuicEncryptedPacket& packet,
-                                int* error) OVERRIDE {
+  virtual WriteResult WritePacketToWire(
+      const QuicEncryptedPacket& packet) OVERRIDE {
     QuicFramer framer(QuicVersionMax(), QuicTime::Zero(), true);
     FramerVisitorCapturingFrames visitor;
     framer.set_visitor(&visitor);
     EXPECT_TRUE(framer.ProcessPacket(packet));
     header_ = *visitor.header();
-    *error = 0;
-    return packet.length();
+    return WriteResult(WRITE_STATUS_OK, packet.length());
   }
 
   QuicPacketHeader* header() { return &header_; }
@@ -81,7 +80,7 @@
         send_algorithm_(new testing::StrictMock<MockSendAlgorithm>),
         helper_(new TestConnectionHelper(0, &epoll_server_)),
         connection_(guid_, IPEndPoint(), helper_),
-        frame1_(3, false, 0, data1) {
+        frame_(3, false, 0, kData) {
     connection_.set_visitor(&visitor_);
     connection_.SetSendAlgorithm(send_algorithm_);
     epoll_server_.set_timeout_in_us(-1);
@@ -97,18 +96,18 @@
 
   QuicPacket* ConstructDataPacket(QuicPacketSequenceNumber number,
                                   QuicFecGroupNumber fec_group) {
-    header_.public_header.version_flag = false;
-    header_.public_header.reset_flag = false;
-    header_.fec_flag = false;
-    header_.entropy_flag = false;
-    header_.packet_sequence_number = number;
-    header_.is_in_fec_group = fec_group == 0 ? NOT_IN_FEC_GROUP : IN_FEC_GROUP;
-    header_.fec_group = fec_group;
+    QuicPacketHeader header;
+    header.public_header.version_flag = false;
+    header.public_header.reset_flag = false;
+    header.fec_flag = false;
+    header.entropy_flag = false;
+    header.packet_sequence_number = number;
+    header.is_in_fec_group = fec_group == 0 ? NOT_IN_FEC_GROUP : IN_FEC_GROUP;
+    header.fec_group = fec_group;
 
     QuicFrames frames;
-    QuicFrame frame(&frame1_);
-    frames.push_back(frame);
-    return framer_.BuildUnsizedDataPacket(header_, frames).packet;
+    frames.push_back(QuicFrame(&frame_));
+    return framer_.BuildUnsizedDataPacket(header, frames).packet;
   }
 
   QuicGuid guid_;
@@ -120,8 +119,7 @@
   TestConnection connection_;
   testing::StrictMock<MockConnectionVisitor> visitor_;
 
-  QuicPacketHeader header_;
-  QuicStreamFrame frame1_;
+  QuicStreamFrame frame_;
 };
 
 TEST_F(QuicEpollConnectionHelperTest, DISABLED_TestRTORetransmission) {
diff --git a/net/tools/quic/quic_in_memory_cache.cc b/net/tools/quic/quic_in_memory_cache.cc
index 8e97f55..c7c7cd0 100644
--- a/net/tools/quic/quic_in_memory_cache.cc
+++ b/net/tools/quic/quic_in_memory_cache.cc
@@ -8,6 +8,7 @@
 #include "base/files/file_enumerator.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
+#include "net/tools/balsa/balsa_headers.h"
 
 using base::FilePath;
 using base::StringPiece;
@@ -20,20 +21,17 @@
 namespace net {
 namespace tools {
 
-std::string FLAGS_quic_in_memory_cache_dir = "/tmp/quic-data";
+std::string FLAGS_quic_in_memory_cache_dir = "";
 
 namespace {
 
 // BalsaVisitor implementation (glue) which caches response bodies.
-class CachingBalsaVisitor : public BalsaVisitorInterface {
+class CachingBalsaVisitor : public NoOpBalsaVisitor {
  public:
   CachingBalsaVisitor() : done_framing_(false) {}
   virtual void ProcessBodyData(const char* input, size_t size) OVERRIDE {
     AppendToBody(input, size);
   }
-  virtual void ProcessTrailers(const BalsaHeaders& trailer) {
-    LOG(DFATAL) << "Trailers not supported.";
-  }
   virtual void MessageDone() OVERRIDE {
     done_framing_ = true;
   }
@@ -43,8 +41,6 @@
   virtual void HandleHeaderWarning(BalsaFrame* framer) OVERRIDE {
     UnhandledError();
   }
-  virtual void HandleTrailerError(BalsaFrame* framer) { UnhandledError(); }
-  virtual void HandleTrailerWarning(BalsaFrame* framer) { UnhandledError(); }
   virtual void HandleChunkingError(BalsaFrame* framer) OVERRIDE {
     UnhandledError();
   }
@@ -54,20 +50,6 @@
   void UnhandledError() {
     LOG(DFATAL) << "Unhandled error framing HTTP.";
   }
-  virtual void ProcessBodyInput(const char*, size_t) OVERRIDE {}
-  virtual void ProcessHeaderInput(const char*, size_t) OVERRIDE {}
-  virtual void ProcessTrailerInput(const char*, size_t) OVERRIDE {}
-  virtual void ProcessHeaders(const net::BalsaHeaders&) OVERRIDE {}
-  virtual void ProcessRequestFirstLine(
-      const char*, size_t, const char*, size_t,
-      const char*, size_t, const char*, size_t) OVERRIDE {}
-  virtual void ProcessResponseFirstLine(
-      const char*, size_t, const char*,
-      size_t, const char*, size_t, const char*, size_t) OVERRIDE {}
-  virtual void ProcessChunkLength(size_t) OVERRIDE {}
-  virtual void ProcessChunkExtensions(const char*, size_t) OVERRIDE {}
-  virtual void HeaderDone() OVERRIDE {}
-
   void AppendToBody(const char* input, size_t size) {
     body_.append(input, size);
   }
@@ -81,6 +63,7 @@
 
 }  // namespace
 
+// static
 QuicInMemoryCache* QuicInMemoryCache::GetInstance() {
   return Singleton<QuicInMemoryCache>::get();
 }
@@ -94,12 +77,12 @@
   return it->second;
 }
 
-void QuicInMemoryCache::AddOrVerifyResponse(StringPiece method,
-                                            StringPiece path,
-                                            StringPiece version,
-                                            StringPiece response_code,
-                                            StringPiece response_detail,
-                                            StringPiece body) {
+void QuicInMemoryCache::AddSimpleResponse(StringPiece method,
+                                          StringPiece path,
+                                          StringPiece version,
+                                          StringPiece response_code,
+                                          StringPiece response_detail,
+                                          StringPiece body) {
   BalsaHeaders request_headers, response_headers;
   request_headers.SetRequestFirstlineFromStringPieces(method,
                                                       path,
@@ -110,18 +93,7 @@
   response_headers.AppendHeader("content-length",
                                 base::IntToString(body.length()));
 
-  // Check if response already exists and matches.
-  const QuicInMemoryCache::Response* cached_response =
-      GetResponse(request_headers);
-  if (cached_response == NULL) {
-    AddResponse(request_headers, response_headers, body);
-    return;
-  }
-  string cached_response_headers_str, response_headers_str;
-  cached_response->headers().DumpToString(&cached_response_headers_str);
-  response_headers.DumpToString(&response_headers_str);
-  CHECK_EQ(cached_response_headers_str, response_headers_str);
-  CHECK_EQ(cached_response->body(), body);
+  AddResponse(request_headers, response_headers, body);
 }
 
 void QuicInMemoryCache::AddResponse(const BalsaHeaders& request_headers,
@@ -130,6 +102,7 @@
   LOG(INFO) << "Adding response for: " << GetKey(request_headers);
   if (ContainsKey(responses_, GetKey(request_headers))) {
     LOG(DFATAL) << "Response for given request already exists!";
+    return;
   }
   Response* new_response = new Response();
   new_response->set_headers(response_headers);
@@ -137,12 +110,12 @@
   responses_[GetKey(request_headers)] = new_response;
 }
 
-void QuicInMemoryCache::ResetForTests() {
-  STLDeleteValues(&responses_);
+QuicInMemoryCache::QuicInMemoryCache() {
   Initialize();
 }
 
-QuicInMemoryCache::QuicInMemoryCache() {
+void QuicInMemoryCache::ResetForTests() {
+  STLDeleteValues(&responses_);
   Initialize();
 }
 
diff --git a/net/tools/quic/quic_in_memory_cache.h b/net/tools/quic/quic_in_memory_cache.h
index 94f524a..3be25a6 100644
--- a/net/tools/quic/quic_in_memory_cache.h
+++ b/net/tools/quic/quic_in_memory_cache.h
@@ -10,14 +10,19 @@
 #include "base/containers/hash_tables.h"
 #include "base/memory/singleton.h"
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_frame.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_frame.h"
+#include "net/tools/balsa/balsa_headers.h"
+#include "net/tools/balsa/noop_balsa_visitor.h"
 
 template <typename T> struct DefaultSingletonTraits;
 
 namespace net {
 namespace tools {
 
+namespace test {
+class QuicInMemoryCachePeer;
+}  // namespace
+
 extern std::string FLAGS_quic_in_memory_cache_dir;
 
 class QuicServer;
@@ -51,6 +56,8 @@
 
     DISALLOW_COPY_AND_ASSIGN(Response);
   };
+
+  // Returns the singleton instance of the cache.
   static QuicInMemoryCache* GetInstance();
 
   // Retrieve a response from this cache for a given request.
@@ -58,30 +65,32 @@
   // Currently, responses are selected based on request URI only.
   const Response* GetResponse(const BalsaHeaders& request_headers) const;
 
-  // Adds a response to the cache if no matching entry exists.
-  // Otherwise it verifies that the existing entry matches.
-  void AddOrVerifyResponse(base::StringPiece method,
-                           base::StringPiece path,
-                           base::StringPiece version,
-                           base::StringPiece response_code,
-                           base::StringPiece response_detail,
-                           base::StringPiece body);
+  // Adds a simple response to the cache.  The response headers will
+  // only contain the "content-length" header with the lenght of |body|.
+  void AddSimpleResponse(base::StringPiece method,
+                         base::StringPiece path,
+                         base::StringPiece version,
+                         base::StringPiece response_code,
+                         base::StringPiece response_detail,
+                         base::StringPiece body);
 
   // Add a response to the cache.
   void AddResponse(const BalsaHeaders& request_headers,
                    const BalsaHeaders& response_headers,
                    base::StringPiece response_body);
 
-  void ResetForTests();
-
  private:
   typedef base::hash_map<std::string, Response*> ResponseMap;
   friend struct DefaultSingletonTraits<QuicInMemoryCache>;
+  friend class test::QuicInMemoryCachePeer;
 
   QuicInMemoryCache();
   ~QuicInMemoryCache();
 
+  void ResetForTests();
+
   void Initialize();
+
   std::string GetKey(const BalsaHeaders& response_headers) const;
 
   // Cached responses.
diff --git a/net/tools/quic/quic_in_memory_cache_test.cc b/net/tools/quic/quic_in_memory_cache_test.cc
index 065ecc3..adcb599 100644
--- a/net/tools/quic/quic_in_memory_cache_test.cc
+++ b/net/tools/quic/quic_in_memory_cache_test.cc
@@ -9,8 +9,9 @@
 #include "base/path_service.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 #include "net/tools/quic/quic_in_memory_cache.h"
+#include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 using base::IntToString;
@@ -39,7 +40,7 @@
   }
 
   virtual void SetUp() {
-    QuicInMemoryCache::GetInstance()->ResetForTests();
+    QuicInMemoryCachePeer::ResetForTests();
   }
 
   // This method was copied from end_to_end_test.cc in this directory.
diff --git a/net/tools/quic/quic_packet_writer.h b/net/tools/quic/quic_packet_writer.h
index b10e852..2d70e09 100644
--- a/net/tools/quic/quic_packet_writer.h
+++ b/net/tools/quic/quic_packet_writer.h
@@ -6,10 +6,12 @@
 #define NET_TOOLS_QUIC_QUIC_PACKET_WRITER_H_
 
 #include "net/base/ip_endpoint.h"
+#include "net/quic/quic_protocol.h"
 
 namespace net {
 
 class QuicBlockedWriterInterface;
+struct WriteResult;
 
 namespace tools {
 
@@ -20,11 +22,11 @@
  public:
   virtual ~QuicPacketWriter() {}
 
-  virtual int WritePacket(const char* buffer, size_t buf_len,
-                          const net::IPAddressNumber& self_address,
-                          const net::IPEndPoint& peer_address,
-                          QuicBlockedWriterInterface* blocked_writer,
-                          int* error) = 0;
+  virtual WriteResult WritePacket(
+      const char* buffer, size_t buf_len,
+      const net::IPAddressNumber& self_address,
+      const net::IPEndPoint& peer_address,
+      QuicBlockedWriterInterface* blocked_writer) = 0;
 };
 
 }  // namespace tools
diff --git a/net/tools/quic/quic_reliable_client_stream.h b/net/tools/quic/quic_reliable_client_stream.h
index 10b60c2..3944b7f 100644
--- a/net/tools/quic/quic_reliable_client_stream.h
+++ b/net/tools/quic/quic_reliable_client_stream.h
@@ -11,8 +11,8 @@
 #include "base/strings/string_piece.h"
 #include "net/quic/quic_protocol.h"
 #include "net/quic/reliable_quic_stream.h"
-#include "net/tools/flip_server/balsa_frame.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_frame.h"
+#include "net/tools/balsa/balsa_headers.h"
 
 namespace net {
 
diff --git a/net/tools/quic/quic_reliable_client_stream_test.cc b/net/tools/quic/quic_reliable_client_stream_test.cc
index af0ffd5..d004fac 100644
--- a/net/tools/quic/quic_reliable_client_stream_test.cc
+++ b/net/tools/quic/quic_reliable_client_stream_test.cc
@@ -7,7 +7,7 @@
 #include "base/strings/string_number_conversions.h"
 #include "net/quic/quic_utils.h"
 #include "net/quic/test_tools/quic_test_utils.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_client_session.h"
 #include "net/tools/quic/quic_spdy_client_stream.h"
 #include "net/tools/quic/spdy_utils.h"
@@ -66,7 +66,7 @@
   EXPECT_EQ(body_, stream_->data());
 }
 
-TEST_F(QuicClientStreamTest, TestFramingExtraData) {
+TEST_F(QuicClientStreamTest, DISABLED_TestFramingExtraData) {
   string large_body = "hello world!!!!!!";
 
   EXPECT_EQ(headers_string_.size(), stream_->ProcessData(
@@ -93,4 +93,3 @@
 }  // namespace test
 }  // namespace tools
 }  // namespace net
-
diff --git a/net/tools/quic/quic_reliable_server_stream.h b/net/tools/quic/quic_reliable_server_stream.h
index 2ece460..d0a389b 100644
--- a/net/tools/quic/quic_reliable_server_stream.h
+++ b/net/tools/quic/quic_reliable_server_stream.h
@@ -9,7 +9,7 @@
 
 #include "net/quic/quic_protocol.h"
 #include "net/quic/reliable_quic_stream.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 
 namespace net {
 
diff --git a/net/tools/quic/quic_reliable_server_stream_test.cc b/net/tools/quic/quic_reliable_server_stream_test.cc
index 53533a3..d33feee 100644
--- a/net/tools/quic/quic_reliable_server_stream_test.cc
+++ b/net/tools/quic/quic_reliable_server_stream_test.cc
@@ -8,10 +8,11 @@
 #include "net/quic/quic_spdy_compressor.h"
 #include "net/quic/quic_utils.h"
 #include "net/quic/test_tools/quic_test_utils.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_in_memory_cache.h"
 #include "net/tools/quic/quic_spdy_server_stream.h"
 #include "net/tools/quic/spdy_utils.h"
+#include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h"
 #include "net/tools/quic/test_tools/quic_test_utils.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -80,7 +81,7 @@
   }
 
   static void SetUpTestCase() {
-    QuicInMemoryCache::GetInstance()->ResetForTests();
+    QuicInMemoryCachePeer::ResetForTests();
   }
 
   virtual void SetUp() {
diff --git a/net/tools/quic/quic_server.cc b/net/tools/quic/quic_server.cc
index 9eae4ab..a5c1e5b 100644
--- a/net/tools/quic/quic_server.cc
+++ b/net/tools/quic/quic_server.cc
@@ -28,7 +28,6 @@
 #endif
 
 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET;
-const int kNumPacketsPerReadCall = 5;  // Arbitrary
 static const char kSourceAddressTokenSecret[] = "secret";
 
 namespace net {
diff --git a/net/tools/quic/quic_server.h b/net/tools/quic/quic_server.h
index 90863ce..e537c3b 100644
--- a/net/tools/quic/quic_server.h
+++ b/net/tools/quic/quic_server.h
@@ -13,7 +13,7 @@
 #include "net/quic/crypto/crypto_server_config.h"
 #include "net/quic/quic_config.h"
 #include "net/quic/quic_framer.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_dispatcher.h"
 
 namespace net {
diff --git a/net/tools/quic/quic_server_bin.cc b/net/tools/quic/quic_server_bin.cc
index cccf578..a71cbcf 100644
--- a/net/tools/quic/quic_server_bin.cc
+++ b/net/tools/quic/quic_server_bin.cc
@@ -5,6 +5,8 @@
 // A binary wrapper for QuicServer.  It listens forever on --port
 // (default 6121) until it's killed or ctrl-cd to death.
 
+#include <iostream>
+
 #include "base/at_exit.h"
 #include "base/basictypes.h"
 #include "base/command_line.h"
@@ -20,6 +22,19 @@
 int main(int argc, char *argv[]) {
   CommandLine::Init(argc, argv);
   CommandLine* line = CommandLine::ForCurrentProcess();
+  if (line->HasSwitch("h") || line->HasSwitch("help")) {
+    const char* help_str =
+        "Usage: quic_server [options]\n"
+        "\n"
+        "Options:\n"
+        "-h, --help                  show this help message and exit\n"
+        "--port=<port>               specify the port to listen on\n"
+        "--quic_in_memory_cache_dir  directory containing response data\n"
+        "                            to load\n";
+    std::cout << help_str;
+    exit(0);
+  }
+
   if (line->HasSwitch("quic_in_memory_cache_dir")) {
     net::tools::FLAGS_quic_in_memory_cache_dir =
         line->GetSwitchValueASCII("quic_in_memory_cache_dir");
diff --git a/net/tools/quic/quic_server_session_test.cc b/net/tools/quic/quic_server_session_test.cc
index a6f94ab..1412f38 100644
--- a/net/tools/quic/quic_server_session_test.cc
+++ b/net/tools/quic/quic_server_session_test.cc
@@ -11,7 +11,7 @@
 #include "net/quic/test_tools/quic_connection_peer.h"
 #include "net/quic/test_tools/quic_test_utils.h"
 #include "net/quic/test_tools/reliable_quic_stream_peer.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_spdy_server_stream.h"
 #include "net/tools/quic/test_tools/quic_test_utils.h"
 #include "testing/gmock/include/gmock/gmock.h"
diff --git a/net/tools/quic/quic_socket_utils.cc b/net/tools/quic/quic_socket_utils.cc
index 4d7d360..87071a6 100644
--- a/net/tools/quic/quic_socket_utils.cc
+++ b/net/tools/quic/quic_socket_utils.cc
@@ -12,6 +12,7 @@
 #include <string>
 
 #include "base/logging.h"
+#include "net/quic/quic_protocol.h"
 
 #ifndef SO_RXQ_OVFL
 #define SO_RXQ_OVFL 40
@@ -22,28 +23,35 @@
 
 // static
 IPAddressNumber QuicSocketUtils::GetAddressFromMsghdr(struct msghdr *hdr) {
-  IPAddressNumber ret;
   if (hdr->msg_controllen > 0) {
     for (cmsghdr* cmsg = CMSG_FIRSTHDR(hdr);
          cmsg != NULL;
          cmsg = CMSG_NXTHDR(hdr, cmsg)) {
-      const uint8* addr_data = reinterpret_cast<const uint8*>CMSG_DATA(cmsg);
+      const uint8* addr_data = NULL;
       int len = 0;
       if (cmsg->cmsg_type == IPV6_PKTINFO) {
-        len = sizeof(in6_pktinfo);
+        in6_pktinfo* info = reinterpret_cast<in6_pktinfo*>CMSG_DATA(cmsg);
+        in6_addr addr = info->ipi6_addr;
+        addr_data = reinterpret_cast<const uint8*>(&addr);
+        len = sizeof(addr);
       } else if (cmsg->cmsg_type == IP_PKTINFO) {
-        len = sizeof(in_pktinfo);
+        in_pktinfo* info = reinterpret_cast<in_pktinfo*>CMSG_DATA(cmsg);
+        in_addr addr = info->ipi_addr;
+        addr_data = reinterpret_cast<const uint8*>(&addr);
+        len = sizeof(addr);
+      } else {
+        continue;
       }
-      ret.assign(addr_data, addr_data + len);
-      break;
+      return IPAddressNumber(addr_data, addr_data + len);
     }
   }
-  return ret;
+  DCHECK(false) << "Unable to get address from msghdr";
+  return IPAddressNumber();
 }
 
 // static
 bool QuicSocketUtils::GetOverflowFromMsghdr(struct msghdr *hdr,
-                                      int *dropped_packets) {
+                                            int *dropped_packets) {
   if (hdr->msg_controllen > 0) {
     struct cmsghdr *cmsg;
     for (cmsg = CMSG_FIRSTHDR(hdr);
@@ -72,9 +80,9 @@
 
 // static
 int QuicSocketUtils::ReadPacket(int fd, char* buffer, size_t buf_len,
-                          int* dropped_packets,
-                          IPAddressNumber* self_address,
-                          IPEndPoint* peer_address) {
+                                int* dropped_packets,
+                                IPAddressNumber* self_address,
+                                IPEndPoint* peer_address) {
   CHECK(peer_address != NULL);
   const int kSpaceForOverflowAndIp =
       CMSG_SPACE(sizeof(int)) + CMSG_SPACE(sizeof(in6_pktinfo));
@@ -128,10 +136,11 @@
 }
 
 // static
-int QuicSocketUtils::WritePacket(int fd, const char* buffer, size_t buf_len,
-                                 const IPAddressNumber& self_address,
-                                 const IPEndPoint& peer_address,
-                                 int* error) {
+WriteResult QuicSocketUtils::WritePacket(int fd,
+                                         const char* buffer,
+                                         size_t buf_len,
+                                         const IPAddressNumber& self_address,
+                                         const IPEndPoint& peer_address) {
   sockaddr_storage raw_address;
   socklen_t address_len = sizeof(raw_address);
   CHECK(peer_address.ToSockAddr(
@@ -183,8 +192,11 @@
   }
 
   int rc = sendmsg(fd, &hdr, 0);
-  *error = (rc >= 0) ? 0 : errno;
-  return rc;
+  if (rc >= 0) {
+    return WriteResult(WRITE_STATUS_OK, rc);
+  }
+  return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK) ?
+      WRITE_STATUS_BLOCKED : WRITE_STATUS_ERROR, errno);
 }
 
 }  // namespace tools
diff --git a/net/tools/quic/quic_socket_utils.h b/net/tools/quic/quic_socket_utils.h
index bfacc6c..8f0feff 100644
--- a/net/tools/quic/quic_socket_utils.h
+++ b/net/tools/quic/quic_socket_utils.h
@@ -12,6 +12,7 @@
 #include <string>
 
 #include "net/base/ip_endpoint.h"
+#include "net/quic/quic_protocol.h"
 
 namespace net {
 namespace tools {
@@ -45,12 +46,13 @@
                         IPAddressNumber* self_address,
                         IPEndPoint* peer_address);
 
-  // Writes buf_len to the socket. If writing is successful returns the number
-  // of bytes written otherwise returns -1 and sets error to errno.
-  static int WritePacket(int fd, const char* buffer, size_t buf_len,
-                         const IPAddressNumber& self_address,
-                         const IPEndPoint& peer_address,
-                         int* error);
+  // Writes buf_len to the socket. If writing is successful, sets the result's
+  // status to WRITE_STATUS_OK and sets bytes_written.  Otherwise sets the
+  // result's status to WRITE_STATUS_BLOCKED or WRITE_STATUS_ERROR and sets
+  // error_code to errno.
+  static WriteResult WritePacket(int fd, const char* buffer, size_t buf_len,
+                                 const IPAddressNumber& self_address,
+                                 const IPEndPoint& peer_address);
 };
 
 }  // namespace tools
diff --git a/net/tools/quic/quic_spdy_client_stream.cc b/net/tools/quic/quic_spdy_client_stream.cc
index 39ffa80..a5dbc3f 100644
--- a/net/tools/quic/quic_spdy_client_stream.cc
+++ b/net/tools/quic/quic_spdy_client_stream.cc
@@ -91,6 +91,7 @@
     Close(QUIC_BAD_APPLICATION_PAYLOAD);
     return -1;
   }
+  response_headers_received_ = true;
 
   size_t delta = read_buf_len - len;
   if (delta > 0) {
diff --git a/net/tools/quic/quic_time_wait_list_manager.cc b/net/tools/quic/quic_time_wait_list_manager.cc
index a2fc4f8..345ddb2 100644
--- a/net/tools/quic/quic_time_wait_list_manager.cc
+++ b/net/tools/quic/quic_time_wait_list_manager.cc
@@ -263,22 +263,19 @@
 
 void QuicTimeWaitListManager::WriteToWire(QueuedPacket* queued_packet) {
   DCHECK(!is_write_blocked_);
-  int error;
-  int rc = writer_->WritePacket(queued_packet->packet()->data(),
-                                queued_packet->packet()->length(),
-                                queued_packet->server_address().address(),
-                                queued_packet->client_address(),
-                                this,
-                                &error);
+  WriteResult result = writer_->WritePacket(
+      queued_packet->packet()->data(),
+      queued_packet->packet()->length(),
+      queued_packet->server_address().address(),
+      queued_packet->client_address(),
+      this);
 
-  if (rc == -1) {
-    if (error == EAGAIN || error == EWOULDBLOCK) {
-      is_write_blocked_ = true;
-    } else {
-      LOG(WARNING) << "Received unknown error while sending reset packet to "
-                   << queued_packet->client_address().ToString() << ": "
-                   << strerror(error);
-    }
+  if (result.status == WRITE_STATUS_BLOCKED) {
+    is_write_blocked_ = true;
+  } else if (result.status == WRITE_STATUS_ERROR) {
+    LOG(WARNING) << "Received unknown error while sending reset packet to "
+                 << queued_packet->client_address().ToString() << ": "
+                 << strerror(result.error_code);
   }
 }
 
diff --git a/net/tools/quic/quic_time_wait_list_manager.h b/net/tools/quic/quic_time_wait_list_manager.h
index 815b9d9..739e14b 100644
--- a/net/tools/quic/quic_time_wait_list_manager.h
+++ b/net/tools/quic/quic_time_wait_list_manager.h
@@ -15,7 +15,7 @@
 #include "net/quic/quic_blocked_writer_interface.h"
 #include "net/quic/quic_framer.h"
 #include "net/quic/quic_protocol.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_epoll_clock.h"
 #include "net/tools/quic/quic_packet_writer.h"
 
diff --git a/net/tools/quic/quic_time_wait_list_manager_test.cc b/net/tools/quic/quic_time_wait_list_manager_test.cc
index 8f59687..64abb61 100644
--- a/net/tools/quic/quic_time_wait_list_manager_test.cc
+++ b/net/tools/quic/quic_time_wait_list_manager_test.cc
@@ -195,11 +195,10 @@
   EXPECT_CALL(writer_, WritePacket(_, _,
                                    server_address_.address(),
                                    client_address_,
-                                   &time_wait_list_manager_,
-                                   _))
+                                   &time_wait_list_manager_))
       .With(Args<0, 1>(PublicResetPacketEq(guid_,
                                            kRandomSequenceNumber)))
-      .WillOnce(Return(packet->length()));
+      .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
 
   ProcessPacket(guid_, *packet);
 }
@@ -210,7 +209,7 @@
   QuicEncryptedPacket packet(buffer, arraysize(buffer));
   ProcessPacket(guid_, packet);
   // Will get called for a valid packet since received packet count = 1 (2 ^ 0).
-  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _, _)).Times(0);
+  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _)).Times(0);
 }
 
 TEST_F(QuicTimeWaitListManagerTest, DropPublicResetPacket) {
@@ -225,7 +224,7 @@
       QuicFramer::BuildPublicResetPacket(packet));
   ProcessPacket(guid_, *public_reset_packet);
   // Will get called for a data packet since received packet count = 1 (2 ^ 0).
-  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _, _))
+  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _))
       .Times(0);
 }
 
@@ -235,8 +234,8 @@
     scoped_ptr<QuicEncryptedPacket> packet(
         ConstructEncryptedPacket(guid_, sequence_number));
     if ((sequence_number & (sequence_number - 1)) == 0) {
-      EXPECT_CALL(writer_, WritePacket(_, _, _, _, _, _))
-          .WillOnce(Return(1));
+      EXPECT_CALL(writer_, WritePacket(_, _, _, _, _))
+          .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 1)));
     }
     ProcessPacket(guid_, *packet);
     // Send public reset with exponential back off.
@@ -294,11 +293,10 @@
   EXPECT_CALL(writer_, WritePacket(_, _,
                                    server_address_.address(),
                                    client_address_,
-                                   &time_wait_list_manager_,
-                                   _))
+                                   &time_wait_list_manager_))
       .With(Args<0, 1>(PublicResetPacketEq(guid,
                                            sequence_number)))
-      .WillOnce(Return(packet->length()));
+      .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
   ProcessPacket(guid, *packet);
   EXPECT_FALSE(time_wait_list_manager_.is_write_blocked());
 
@@ -306,11 +304,10 @@
   EXPECT_CALL(writer_, WritePacket(_, _,
                                    server_address_.address(),
                                    client_address_,
-                                   &time_wait_list_manager_,
-                                   _))
+                                   &time_wait_list_manager_))
       .With(Args<0, 1>(PublicResetPacketEq(guid,
                                            sequence_number)))
-      .WillOnce(DoAll(SetArgPointee<5>(EAGAIN), Return(-1)));
+      .WillOnce(Return(WriteResult(WRITE_STATUS_BLOCKED, EAGAIN)));
   ProcessPacket(guid, *packet);
   // 3rd packet. No public reset should be sent;
   ProcessPacket(guid, *packet);
@@ -323,7 +320,7 @@
   QuicPacketSequenceNumber other_sequence_number = 23423;
   scoped_ptr<QuicEncryptedPacket> other_packet(
       ConstructEncryptedPacket(other_guid, other_sequence_number));
-  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _, _))
+  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _))
       .Times(0);
   ProcessPacket(other_guid, *other_packet);
 
@@ -331,19 +328,18 @@
   EXPECT_CALL(writer_, WritePacket(_, _,
                                    server_address_.address(),
                                    client_address_,
-                                   &time_wait_list_manager_,
-                                   _))
+                                   &time_wait_list_manager_))
       .With(Args<0, 1>(PublicResetPacketEq(guid,
                                            sequence_number)))
-      .WillOnce(Return(packet->length()));
+      .WillOnce(Return(WriteResult(WRITE_STATUS_OK, packet->length())));
   EXPECT_CALL(writer_, WritePacket(_, _,
                                    server_address_.address(),
                                    client_address_,
-                                   &time_wait_list_manager_,
-                                   _))
+                                   &time_wait_list_manager_))
       .With(Args<0, 1>(PublicResetPacketEq(other_guid,
                                            other_sequence_number)))
-      .WillOnce(Return(other_packet->length()));
+      .WillOnce(Return(WriteResult(WRITE_STATUS_OK,
+                                   other_packet->length())));
   time_wait_list_manager_.OnCanWrite();
   EXPECT_FALSE(time_wait_list_manager_.is_write_blocked());
 }
@@ -357,7 +353,8 @@
   packet.reset(ConstructEncryptedPacket(guid_, kRandomSequenceNumber));
 
   // Reset packet should be written, using the minimum quic version.
-  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _, _)).Times(1);
+  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _)).Times(1)
+      .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
   ProcessPacket(guid_, *packet);
   EXPECT_EQ(time_wait_list_manager_.version(), QuicVersionMin());
 
@@ -369,7 +366,8 @@
   packet.reset(ConstructEncryptedPacket(guid_, kRandomSequenceNumber));
 
   // Reset packet should be written, using the maximum quic version.
-  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _, _)).Times(1);
+  EXPECT_CALL(writer_, WritePacket(_, _, _, _, _)).Times(1)
+    .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
   ProcessPacket(guid_, *packet);
   EXPECT_EQ(time_wait_list_manager_.version(), QuicVersionMax());
 }
diff --git a/net/tools/quic/spdy_utils.cc b/net/tools/quic/spdy_utils.cc
index 13d05e5..c350a96 100644
--- a/net/tools/quic/spdy_utils.cc
+++ b/net/tools/quic/spdy_utils.cc
@@ -13,7 +13,7 @@
 #include "net/spdy/spdy_frame_builder.h"
 #include "net/spdy/spdy_framer.h"
 #include "net/spdy/spdy_protocol.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 #include "url/gurl.h"
 
 using base::StringPiece;
@@ -250,10 +250,10 @@
     return false;
   }
 
-  request_headers->SetRequestVersion(version_it->second);
   if (!ParseReasonAndStatus(status_it->second, request_headers)) {
     return false;
   }
+  request_headers->SetResponseVersion(version_it->second);
   for (BlockIt it = header_block.begin(); it != header_block.end(); ++it) {
    if (!IsSpecialSpdyHeader(it, request_headers)) {
      request_headers->AppendHeader(it->first, it->second);
diff --git a/net/tools/quic/spdy_utils.h b/net/tools/quic/spdy_utils.h
index 4478274..cfad5f1 100644
--- a/net/tools/quic/spdy_utils.h
+++ b/net/tools/quic/spdy_utils.h
@@ -10,7 +10,7 @@
 #include "net/spdy/spdy_framer.h"
 #include "net/spdy/spdy_header_block.h"
 #include "net/spdy/spdy_protocol.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 
 namespace net {
 namespace tools {
diff --git a/net/tools/quic/test_tools/http_message_test_utils.h b/net/tools/quic/test_tools/http_message_test_utils.h
index d389e21..fefdb49 100644
--- a/net/tools/quic/test_tools/http_message_test_utils.h
+++ b/net/tools/quic/test_tools/http_message_test_utils.h
@@ -9,8 +9,8 @@
 #include <vector>
 
 #include "base/strings/string_piece.h"
-#include "net/tools/flip_server/balsa_enums.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_enums.h"
+#include "net/tools/balsa/balsa_headers.h"
 
 namespace net {
 namespace tools {
diff --git a/net/tools/quic/test_tools/mock_epoll_server.h b/net/tools/quic/test_tools/mock_epoll_server.h
index 710d5fd..fbc1695 100644
--- a/net/tools/quic/test_tools/mock_epoll_server.h
+++ b/net/tools/quic/test_tools/mock_epoll_server.h
@@ -6,7 +6,7 @@
 #define NET_TOOLS_QUIC_TEST_TOOLS_MOCK_EPOLL_SERVER_H_
 
 #include "base/logging.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "testing/gmock/include/gmock/gmock.h"
 
 namespace net {
diff --git a/net/tools/quic/test_tools/mock_quic_dispatcher.h b/net/tools/quic/test_tools/mock_quic_dispatcher.h
index 563ab0d..ac198bc 100644
--- a/net/tools/quic/test_tools/mock_quic_dispatcher.h
+++ b/net/tools/quic/test_tools/mock_quic_dispatcher.h
@@ -9,7 +9,7 @@
 #include "net/quic/crypto/crypto_server_config.h"
 #include "net/quic/quic_config.h"
 #include "net/quic/quic_protocol.h"
-#include "net/tools/flip_server/epoll_server.h"
+#include "net/tools/epoll_server/epoll_server.h"
 #include "net/tools/quic/quic_dispatcher.h"
 #include "testing/gmock/include/gmock/gmock.h"
 
diff --git a/net/tools/quic/test_tools/quic_in_memory_cache_peer.cc b/net/tools/quic/test_tools/quic_in_memory_cache_peer.cc
new file mode 100644
index 0000000..feb506e
--- /dev/null
+++ b/net/tools/quic/test_tools/quic_in_memory_cache_peer.cc
@@ -0,0 +1,20 @@
+// 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.
+
+#include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h"
+
+#include "net/tools/quic/quic_in_memory_cache.h"
+
+namespace net {
+namespace tools {
+namespace test {
+
+// static
+void QuicInMemoryCachePeer::ResetForTests() {
+  QuicInMemoryCache::GetInstance()->ResetForTests();
+}
+
+}  // namespace test
+}  // namespace tools
+}  // namespace net
diff --git a/net/tools/quic/test_tools/quic_in_memory_cache_peer.h b/net/tools/quic/test_tools/quic_in_memory_cache_peer.h
new file mode 100644
index 0000000..b5996bd
--- /dev/null
+++ b/net/tools/quic/test_tools/quic_in_memory_cache_peer.h
@@ -0,0 +1,27 @@
+// 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 NET_TOOLS_QUIC_TEST_TOOLS_QUIC_IN_MEMORY_CACHE_PEER_H_
+#define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_IN_MEMORY_CACHE_PEER_H_
+
+#include "net/tools/quic/quic_in_memory_cache.h"
+
+namespace net {
+namespace tools {
+namespace test {
+
+class QuicInMemoryCachePeer {
+ public:
+  // Resets the singleton QuicInMemoryCache to a fresh state.
+  static void ResetForTests();
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(QuicInMemoryCachePeer);
+};
+
+}  // namespace test
+}  // namespace tools
+}  // namespace net
+
+#endif  // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_IN_MEMORY_CACHE_PEER_H_
diff --git a/net/tools/quic/test_tools/quic_test_client.cc b/net/tools/quic/test_tools/quic_test_client.cc
index 272786e..0af8949 100644
--- a/net/tools/quic/test_tools/quic_test_client.cc
+++ b/net/tools/quic/test_tools/quic_test_client.cc
@@ -9,7 +9,7 @@
 #include "net/cert/cert_verify_result.h"
 #include "net/cert/x509_certificate.h"
 #include "net/quic/crypto/proof_verifier.h"
-#include "net/tools/flip_server/balsa_headers.h"
+#include "net/tools/balsa/balsa_headers.h"
 #include "net/tools/quic/quic_epoll_connection_helper.h"
 #include "net/tools/quic/quic_spdy_client_stream.h"
 #include "net/tools/quic/test_tools/http_message_test_utils.h"
@@ -98,7 +98,7 @@
   QuicEpollClient(IPEndPoint server_address,
              const string& server_hostname,
              const QuicVersion version)
-      : Super(server_address, server_hostname, version) {
+      : Super(server_address, server_hostname, version, false) {
   }
 
   QuicEpollClient(IPEndPoint server_address,
diff --git a/net/tools/quic/test_tools/quic_test_utils.h b/net/tools/quic/test_tools/quic_test_utils.h
index dffa255..2710a56 100644
--- a/net/tools/quic/test_tools/quic_test_utils.h
+++ b/net/tools/quic/test_tools/quic_test_utils.h
@@ -125,12 +125,12 @@
   MockPacketWriter();
   virtual ~MockPacketWriter();
 
-  MOCK_METHOD6(WritePacket, int(const char* buffer,
-                                size_t buf_len,
-                                const IPAddressNumber& self_address,
-                                const IPEndPoint& peer_address,
-                                QuicBlockedWriterInterface* blocked_writer,
-                                int* error));
+  MOCK_METHOD5(WritePacket,
+               WriteResult(const char* buffer,
+                           size_t buf_len,
+                           const IPAddressNumber& self_address,
+                           const IPEndPoint& peer_address,
+                           QuicBlockedWriterInterface* blocked_writer));
 };
 
 }  // namespace test