1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #include "syzygy/kasko/testing/mock_service.h"
16 :
17 : namespace kasko {
18 : namespace testing {
19 :
20 : MockService::MockService(std::vector<CallRecord>* call_log)
21 E : : call_log_(call_log) {}
22 :
23 E : MockService::~MockService() {}
24 :
25 : void MockService::SendDiagnosticReport(base::ProcessId client_process_id,
26 : base::PlatformThreadId thread_id,
27 E : const MinidumpRequest& request) {
28 E : std::map<base::string16, base::string16> crash_keys;
29 E : for (auto& crash_key : request.crash_keys) {
30 E : crash_keys[crash_key.first] = crash_key.second;
31 E : }
32 :
33 E : std::map<uint32_t, std::string> custom_streams;
34 E : for (auto& custom_stream : request.custom_streams) {
35 : custom_streams[custom_stream.type] =
36 : std::string(reinterpret_cast<const char*>(custom_stream.data),
37 E : custom_stream.length);
38 E : }
39 :
40 : CallRecord record = {
41 : client_process_id, request.exception_info_address, thread_id,
42 : request.type, request.user_selected_memory_ranges, crash_keys,
43 E : custom_streams};
44 :
45 E : call_log_->push_back(record);
46 E : }
47 :
48 : } // namespace testing
49 : } // namespace kasko
|