Index: chrome/browser/password_manager/keyring_proxy/message_reader.h |
=================================================================== |
--- chrome/browser/password_manager/keyring_proxy/message_reader.h (revision 0) |
+++ chrome/browser/password_manager/keyring_proxy/message_reader.h (revision 0) |
@@ -0,0 +1,45 @@ |
+// 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. |
+ |
+#ifndef CHROME_BROWSER_PASSWORD_MANAGER_KEYRING_PROXY_MESSAGE_READER_H_ |
+#define CHROME_BROWSER_PASSWORD_MANAGER_KEYRING_PROXY_MESSAGE_READER_H_ |
+#pragma once |
+ |
+#include <string> |
+#include <vector> |
+ |
+namespace keyring_proxy { |
+ |
+// This class handles reading bits and pieces of input data and assembling them |
+// into a set of newline-delimited lines. Each message is terminated by a blank |
+// line. (Think HTTP, SMTP, etc.) |
+// It is used in the (tiny) helper binary as well as the browser process, so it |
+// must not have any dependencies beyond standard libraries. |
+class MessageReader { |
+ public: |
+ MessageReader() : is_complete_(false) { lines_.resize(1); } |
+ |
+ // Returns the number of characters actually used; on end-of-message, |
+ // this may be smaller than |size|, but should otherwise be equal. |
+ // It is an error to call HandleData() if is_complete() would return true. |
+ size_t HandleData(const char* data, size_t size); |
+ |
+ bool is_complete() const { return is_complete_; } |
+ const std::vector<std::string>& lines() const { return lines_; } |
+ |
+ // Resets internal state so the reader will be ready for another message. |
+ void Reset() { |
+ lines_.clear(); |
+ lines_.resize(1); |
+ is_complete_ = false; |
+ } |
+ |
+ private: |
+ bool is_complete_; |
+ std::vector<std::string> lines_; |
+}; |
+ |
+} // namespace keyring_proxy |
+ |
+#endif // CHROME_BROWSER_PASSWORD_MANAGER_KEYRING_PROXY_MESSAGE_READER_H_ |
Property changes on: chrome/browser/password_manager/keyring_proxy/message_reader.h |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |