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

Side by Side Diff: base/debug/proc_maps_linux.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ash/desktop_background/desktop_background_controller.cc ('k') | base/file_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/debug/proc_maps_linux.h" 5 #include "base/debug/proc_maps_linux.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <inttypes.h> 8 #include <inttypes.h>
9 #endif 9 #endif
10 10
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 13
14 #if defined(OS_ANDROID) 14 #if defined(OS_ANDROID)
15 // Bionic's inttypes.h defines PRI/SCNxPTR as an unsigned long int, which 15 // Bionic's inttypes.h defines PRI/SCNxPTR as an unsigned long int, which
16 // is incompatible with Bionic's stdint.h defining uintptr_t as a unsigned int: 16 // is incompatible with Bionic's stdint.h defining uintptr_t as a unsigned int:
17 // https://code.google.com/p/android/issues/detail?id=57218 17 // https://code.google.com/p/android/issues/detail?id=57218
18 #undef SCNxPTR 18 #undef SCNxPTR
19 #define SCNxPTR "x" 19 #define SCNxPTR "x"
20 #endif 20 #endif
21 21
22 namespace base { 22 namespace base {
23 namespace debug { 23 namespace debug {
24 24
25 bool ReadProcMaps(std::string* proc_maps) { 25 bool ReadProcMaps(std::string* proc_maps) {
26 FilePath proc_maps_path("/proc/self/maps"); 26 FilePath proc_maps_path("/proc/self/maps");
27 return file_util::ReadFileToString(proc_maps_path, proc_maps); 27 return ReadFileToString(proc_maps_path, proc_maps);
28 } 28 }
29 29
30 bool ParseProcMaps(const std::string& input, 30 bool ParseProcMaps(const std::string& input,
31 std::vector<MappedMemoryRegion>* regions_out) { 31 std::vector<MappedMemoryRegion>* regions_out) {
32 std::vector<MappedMemoryRegion> regions; 32 std::vector<MappedMemoryRegion> regions;
33 33
34 // This isn't async safe nor terribly efficient, but it doesn't need to be at 34 // This isn't async safe nor terribly efficient, but it doesn't need to be at
35 // this point in time. 35 // this point in time.
36 std::vector<std::string> lines; 36 std::vector<std::string> lines;
37 SplitString(input, '\n', &lines); 37 SplitString(input, '\n', &lines);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 regions.push_back(region); 92 regions.push_back(region);
93 regions.back().path.assign(line + path_index); 93 regions.back().path.assign(line + path_index);
94 } 94 }
95 95
96 regions_out->swap(regions); 96 regions_out->swap(regions);
97 return true; 97 return true;
98 } 98 }
99 99
100 } // namespace debug 100 } // namespace debug
101 } // namespace base 101 } // namespace base
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_controller.cc ('k') | base/file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698