Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1563)

Unified Diff: net/base/test_data_stream.h

Issue 7056031: Collect stats to investigate the viability of UDP (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/google_chrome_distribution_dummy.cc ('k') | net/base/test_data_stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/test_data_stream.h
===================================================================
--- net/base/test_data_stream.h (revision 85795)
+++ net/base/test_data_stream.h (working copy)
@@ -2,80 +2,40 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_CURVECP_TEST_DATA_STREAM_H_
-#define NET_CURVECP_TEST_DATA_STREAM_H_
+#ifndef NET_BASE_TEST_DATA_STREAM_H_
+#define NET_BASE_TEST_DATA_STREAM_H_
#pragma once
-#include <string.h> // for memcpy()
+#include <string.h> // for memcpy().
#include <algorithm>
+#include "net/base/net_api.h"
-// This is a test class for generating an infinite stream of data which can
-// be verified independently to be the correct stream of data.
+// This is a class for generating an infinite stream of data which can be
+// verified independently to be the correct stream of data.
namespace net {
-class TestDataStream {
+class NET_API TestDataStream {
public:
- TestDataStream() {
- Reset();
- }
+ TestDataStream();
// Fill |buffer| with |length| bytes of data from the stream.
- void GetBytes(char* buffer, int length) {
- while (length) {
- AdvanceIndex();
- int bytes_to_copy = std::min(length, bytes_remaining_);
- memcpy(buffer, buffer_ptr_, bytes_to_copy);
- buffer += bytes_to_copy;
- Consume(bytes_to_copy);
- length -= bytes_to_copy;
- }
- }
+ void GetBytes(char* buffer, int length);
// Verify that |buffer| contains the expected next |length| bytes from the
// stream. Returns true if correct, false otherwise.
- bool VerifyBytes(const char *buffer, int length) {
- while (length) {
- AdvanceIndex();
- int bytes_to_compare = std::min(length, bytes_remaining_);
- if (memcmp(buffer, buffer_ptr_, bytes_to_compare))
- return false;
- Consume(bytes_to_compare);
- length -= bytes_to_compare;
- buffer += bytes_to_compare;
- }
- return true;
- }
+ bool VerifyBytes(const char *buffer, int length);
- void Reset() {
- index_ = 0;
- bytes_remaining_ = 0;
- buffer_ptr_ = buffer_;
- }
+ // Resets all the data.
+ void Reset();
private:
// If there is no data spilled over from the previous index, advance the
// index and fill the buffer.
- void AdvanceIndex() {
- if (bytes_remaining_ == 0) {
- // Convert it to ascii, but don't bother to reverse it.
- // (e.g. 12345 becomes "54321")
- int val = index_++;
- do {
- buffer_[bytes_remaining_++] = (val % 10) + '0';
- } while ((val /= 10) > 0);
- buffer_[bytes_remaining_++] = '.';
- }
- }
+ void AdvanceIndex();
// Consume data from the spill buffer.
- void Consume(int bytes) {
- bytes_remaining_ -= bytes;
- if (bytes_remaining_)
- buffer_ptr_ += bytes;
- else
- buffer_ptr_ = buffer_;
- }
+ void Consume(int bytes);
int index_;
int bytes_remaining_;
@@ -85,4 +45,4 @@
} // namespace net
-#endif // NET_CURVECP_TEST_DATA_STREAM_H_
+#endif // NET_BASE_TEST_DATA_STREAM_H_
« no previous file with comments | « chrome/installer/util/google_chrome_distribution_dummy.cc ('k') | net/base/test_data_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698