Index: chrome/browser/password_manager/keyring_proxy/message_reader.cc |
=================================================================== |
--- chrome/browser/password_manager/keyring_proxy/message_reader.cc (revision 0) |
+++ chrome/browser/password_manager/keyring_proxy/message_reader.cc (revision 0) |
@@ -0,0 +1,40 @@ |
+// Copyright (c) 2011 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 "chrome/browser/password_manager/keyring_proxy/message_reader.h" |
+ |
+// This library is part of a very small helper binary that runs without any |
+// dependencies on base. Thus we can't use normal logging; we use assert. |
+#include <assert.h> |
+ |
+namespace keyring_proxy { |
+ |
+size_t MessageReader::HandleData(const char* data, size_t size) { |
+ assert(!is_complete_); |
+ size_t used = 0; |
+ while (used < size) { |
+ size_t end; |
+ for (end = used; end < size && data[end] != '\n'; ++end) {} |
+ lines_.back().append(&data[used], end - used); |
+ if (end < size) { |
+ // We found a newline. Skip past it and figure out what to do. |
+ used = end + 1; |
+ if (lines_.back().size() > 0) { |
+ // The previous line was not empty. Start a new one. |
+ lines_.resize(lines_.size() + 1); |
+ } else { |
+ // If the previous line was empty, this message is complete. |
+ lines_.resize(lines_.size() - 1); |
+ is_complete_ = true; |
+ break; |
+ } |
+ } else { |
+ // There was no newline, just the end of the input. Skip to the end. |
+ used = end; |
+ } |
+ } |
+ return used; |
+} |
+ |
+} // namespace keyring_proxy |
Property changes on: chrome/browser/password_manager/keyring_proxy/message_reader.cc |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |