Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / logging / win / mof_data_parser.cc
blob027cf1f6576abed896643a30a6518f23d7b5a24e
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/test/logging/win/mof_data_parser.h"
7 namespace logging_win {
9 MofDataParser::MofDataParser(const EVENT_TRACE* event)
10 : scan_(reinterpret_cast<const uint8*>(event->MofData)),
11 length_(event->MofLength) {
14 bool MofDataParser::ReadString(base::StringPiece* value) {
15 const uint8* str_scan = scan_;
16 const uint8* const str_end = str_scan + length_;
17 while (str_scan < str_end && *str_scan != 0)
18 ++str_scan;
19 if (str_scan == str_end)
20 return false;
21 size_t string_length = str_scan - scan_;
22 bool has_trailing_newline = (string_length > 0 && str_scan[-1] == '\n');
23 value->set(reinterpret_cast<const char*>(scan_),
24 has_trailing_newline ? string_length - 1 : string_length);
25 Advance(string_length + 1);
26 return true;
29 } // namespace logging_win