Chromium Code Reviews| Index: chrome/browser/password_manager/proxy/message_reader.h |
| =================================================================== |
| --- chrome/browser/password_manager/proxy/message_reader.h (revision 0) |
| +++ chrome/browser/password_manager/proxy/message_reader.h (revision 0) |
| @@ -0,0 +1,41 @@ |
| +// 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_PROXY_MESSAGE_READER_H_ |
| +#define CHROME_BROWSER_PASSWORD_MANAGER_PROXY_MESSAGE_READER_H_ |
| +#pragma once |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +// 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); } |
|
vandebo (ex-Chrome)
2011/12/01 19:57:30
Put this in the implementation file.
|
| + |
| + // 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() { |
|
vandebo (ex-Chrome)
2011/12/01 19:57:30
Put this in the implementation file.
|
| + lines_.clear(); |
| + lines_.resize(1); |
| + is_complete_ = false; |
| + } |
| + |
| + private: |
| + bool is_complete_; |
| + std::vector<std::string> lines_; |
| +}; |
| + |
| +#endif // CHROME_BROWSER_PASSWORD_MANAGER_PROXY_MESSAGE_READER_H_ |
| Property changes on: chrome/browser/password_manager/proxy/message_reader.h |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |