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

Side by Side Diff: third_party/crashpad/crashpad/util/win/process_info.cc

Issue 1774443002: Replace template_util.h stuff with C++11 <type_traits> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« base/template_util.h ('K') | « third_party/crashpad/README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with 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 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/win/process_info.h" 15 #include "util/win/process_info.h"
16 16
17 #include <winternl.h> 17 #include <winternl.h>
18 18
19 #include <algorithm> 19 #include <algorithm>
20 #include <limits> 20 #include <limits>
21 #include <type_traits>
21 22
22 #include "base/logging.h" 23 #include "base/logging.h"
23 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
24 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
25 #include "base/template_util.h"
26 #include "build/build_config.h" 26 #include "build/build_config.h"
27 #include "util/numeric/safe_assignment.h" 27 #include "util/numeric/safe_assignment.h"
28 #include "util/win/get_function.h" 28 #include "util/win/get_function.h"
29 #include "util/win/handle.h" 29 #include "util/win/handle.h"
30 #include "util/win/nt_internals.h" 30 #include "util/win/nt_internals.h"
31 #include "util/win/ntstatus_logging.h" 31 #include "util/win/ntstatus_logging.h"
32 #include "util/win/process_structs.h" 32 #include "util/win/process_structs.h"
33 #include "util/win/scoped_handle.h" 33 #include "util/win/scoped_handle.h"
34 34
35 namespace crashpad { 35 namespace crashpad {
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 } 629 }
630 630
631 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap( 631 std::vector<CheckedRange<WinVMAddress, WinVMSize>> GetReadableRangesOfMemoryMap(
632 const CheckedRange<WinVMAddress, WinVMSize>& range, 632 const CheckedRange<WinVMAddress, WinVMSize>& range,
633 const ProcessInfo::MemoryBasicInformation64Vector& memory_info) { 633 const ProcessInfo::MemoryBasicInformation64Vector& memory_info) {
634 using Range = CheckedRange<WinVMAddress, WinVMSize>; 634 using Range = CheckedRange<WinVMAddress, WinVMSize>;
635 635
636 // Find all the ranges that overlap the target range, maintaining their order. 636 // Find all the ranges that overlap the target range, maintaining their order.
637 ProcessInfo::MemoryBasicInformation64Vector overlapping; 637 ProcessInfo::MemoryBasicInformation64Vector overlapping;
638 for (const auto& mi : memory_info) { 638 for (const auto& mi : memory_info) {
639 static_assert(base::is_same<decltype(mi.BaseAddress), WinVMAddress>::value, 639 static_assert(std::is_same<decltype(mi.BaseAddress), WinVMAddress>::value,
danakj 2016/03/08 00:23:36 You might need to add these to third_party/crashpa
tzik 2016/03/08 13:13:51 Done.
640 "expected range address to be WinVMAddress"); 640 "expected range address to be WinVMAddress");
641 static_assert(base::is_same<decltype(mi.RegionSize), WinVMSize>::value, 641 static_assert(std::is_same<decltype(mi.RegionSize), WinVMSize>::value,
642 "expected range size to be WinVMSize"); 642 "expected range size to be WinVMSize");
643 if (range.OverlapsRange(Range(mi.BaseAddress, mi.RegionSize))) 643 if (range.OverlapsRange(Range(mi.BaseAddress, mi.RegionSize)))
644 overlapping.push_back(mi); 644 overlapping.push_back(mi);
645 } 645 }
646 if (overlapping.empty()) 646 if (overlapping.empty())
647 return std::vector<Range>(); 647 return std::vector<Range>();
648 648
649 // For the first and last, trim to the boundary of the incoming range. 649 // For the first and last, trim to the boundary of the incoming range.
650 MEMORY_BASIC_INFORMATION64& front = overlapping.front(); 650 MEMORY_BASIC_INFORMATION64& front = overlapping.front();
651 WinVMAddress original_front_base_address = front.BaseAddress; 651 WinVMAddress original_front_base_address = front.BaseAddress;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } else { 684 } else {
685 result.push_back(as_ranges[i]); 685 result.push_back(as_ranges[i]);
686 } 686 }
687 DCHECK(result.back().IsValid()); 687 DCHECK(result.back().IsValid());
688 } 688 }
689 689
690 return result; 690 return result;
691 } 691 }
692 692
693 } // namespace crashpad 693 } // namespace crashpad
OLDNEW
« base/template_util.h ('K') | « third_party/crashpad/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698