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 m : namespace kasko {
18 m : namespace testing {
19 :
20 m : MockService::MockService(std::vector<CallRecord>* call_log)
21 m : : call_log_(call_log) {}
22 :
23 m : MockService::~MockService() {}
24 :
25 m : void MockService::SendDiagnosticReport(base::ProcessId client_process_id,
26 m : base::PlatformThreadId thread_id,
27 m : const MinidumpRequest& request) {
28 m : std::map<base::string16, base::string16> crash_keys;
29 m : for (auto& crash_key : request.crash_keys) {
30 m : crash_keys[crash_key.first] = crash_key.second;
31 m : }
32 :
33 m : std::map<uint32_t, std::string> custom_streams;
34 m : for (auto& custom_stream : request.custom_streams) {
35 m : custom_streams[custom_stream.type] =
36 m : std::string(reinterpret_cast<const char*>(custom_stream.data),
37 m : custom_stream.length);
38 m : }
39 :
40 m : CallRecord record = {
41 m : client_process_id, request.exception_info_address, thread_id,
42 m : request.type, request.user_selected_memory_ranges, crash_keys,
43 m : custom_streams};
44 :
45 m : call_log_->push_back(record);
46 m : }
47 :
48 m : } // namespace testing
49 m : } // namespace kasko
|