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

Side by Side Diff: sandbox/win/src/handle_closer.cc

Issue 111373008: Update some uses of char16 to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | « sandbox/win/src/handle_closer.h ('k') | sandbox/win/src/handle_closer_agent.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "sandbox/win/src/handle_closer.h" 5 #include "sandbox/win/src/handle_closer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "sandbox/win/src/interceptors.h" 10 #include "sandbox/win/src/interceptors.h"
(...skipping 16 matching lines...) Expand all
27 27
28 } // namespace 28 } // namespace
29 29
30 namespace sandbox { 30 namespace sandbox {
31 31
32 // Memory buffer mapped from the parent, with the list of handles. 32 // Memory buffer mapped from the parent, with the list of handles.
33 SANDBOX_INTERCEPT HandleCloserInfo* g_handles_to_close; 33 SANDBOX_INTERCEPT HandleCloserInfo* g_handles_to_close;
34 34
35 HandleCloser::HandleCloser() {} 35 HandleCloser::HandleCloser() {}
36 36
37 ResultCode HandleCloser::AddHandle(const char16* handle_type, 37 ResultCode HandleCloser::AddHandle(const base::char16* handle_type,
38 const char16* handle_name) { 38 const base::char16* handle_name) {
39 if (!handle_type) 39 if (!handle_type)
40 return SBOX_ERROR_BAD_PARAMS; 40 return SBOX_ERROR_BAD_PARAMS;
41 41
42 HandleMap::iterator names = handles_to_close_.find(handle_type); 42 HandleMap::iterator names = handles_to_close_.find(handle_type);
43 if (names == handles_to_close_.end()) { // We have no entries for this type. 43 if (names == handles_to_close_.end()) { // We have no entries for this type.
44 std::pair<HandleMap::iterator, bool> result = handles_to_close_.insert( 44 std::pair<HandleMap::iterator, bool> result = handles_to_close_.insert(
45 HandleMap::value_type(handle_type, HandleMap::mapped_type())); 45 HandleMap::value_type(handle_type, HandleMap::mapped_type()));
46 names = result.first; 46 names = result.first;
47 if (handle_name) 47 if (handle_name)
48 names->second.insert(handle_name); 48 names->second.insert(handle_name);
49 } else if (!handle_name) { // Now we need to close all handles of this type. 49 } else if (!handle_name) { // Now we need to close all handles of this type.
50 names->second.clear(); 50 names->second.clear();
51 } else if (!names->second.empty()) { // Add another name for this type. 51 } else if (!names->second.empty()) { // Add another name for this type.
52 names->second.insert(handle_name); 52 names->second.insert(handle_name);
53 } // If we're already closing all handles of type then we're done. 53 } // If we're already closing all handles of type then we're done.
54 54
55 return SBOX_ALL_OK; 55 return SBOX_ALL_OK;
56 } 56 }
57 57
58 size_t HandleCloser::GetBufferSize() { 58 size_t HandleCloser::GetBufferSize() {
59 size_t bytes_total = offsetof(HandleCloserInfo, handle_entries); 59 size_t bytes_total = offsetof(HandleCloserInfo, handle_entries);
60 60
61 for (HandleMap::iterator i = handles_to_close_.begin(); 61 for (HandleMap::iterator i = handles_to_close_.begin();
62 i != handles_to_close_.end(); ++i) { 62 i != handles_to_close_.end(); ++i) {
63 size_t bytes_entry = offsetof(HandleListEntry, handle_type) + 63 size_t bytes_entry = offsetof(HandleListEntry, handle_type) +
64 (i->first.size() + 1) * sizeof(char16); 64 (i->first.size() + 1) * sizeof(base::char16);
65 for (HandleMap::mapped_type::iterator j = i->second.begin(); 65 for (HandleMap::mapped_type::iterator j = i->second.begin();
66 j != i->second.end(); ++j) { 66 j != i->second.end(); ++j) {
67 bytes_entry += ((*j).size() + 1) * sizeof(char16); 67 bytes_entry += ((*j).size() + 1) * sizeof(base::char16);
68 } 68 }
69 69
70 // Round up to the nearest multiple of word size. 70 // Round up to the nearest multiple of word size.
71 bytes_entry = RoundUpToWordSize(bytes_entry); 71 bytes_entry = RoundUpToWordSize(bytes_entry);
72 bytes_total += bytes_entry; 72 bytes_total += bytes_entry;
73 } 73 }
74 74
75 return bytes_total; 75 return bytes_total;
76 } 76 }
77 77
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 return (SBOX_ALL_OK == rc); 113 return (SBOX_ALL_OK == rc);
114 } 114 }
115 115
116 bool HandleCloser::SetupHandleList(void* buffer, size_t buffer_bytes) { 116 bool HandleCloser::SetupHandleList(void* buffer, size_t buffer_bytes) {
117 ::ZeroMemory(buffer, buffer_bytes); 117 ::ZeroMemory(buffer, buffer_bytes);
118 HandleCloserInfo* handle_info = reinterpret_cast<HandleCloserInfo*>(buffer); 118 HandleCloserInfo* handle_info = reinterpret_cast<HandleCloserInfo*>(buffer);
119 handle_info->record_bytes = buffer_bytes; 119 handle_info->record_bytes = buffer_bytes;
120 handle_info->num_handle_types = handles_to_close_.size(); 120 handle_info->num_handle_types = handles_to_close_.size();
121 121
122 char16* output = reinterpret_cast<char16*>(&handle_info->handle_entries[0]); 122 base::char16* output = reinterpret_cast<base::char16*>(
123 char16* end = reinterpret_cast<char16*>( 123 &handle_info->handle_entries[0]);
124 base::char16* end = reinterpret_cast<base::char16*>(
124 reinterpret_cast<char*>(buffer) + buffer_bytes); 125 reinterpret_cast<char*>(buffer) + buffer_bytes);
125 for (HandleMap::iterator i = handles_to_close_.begin(); 126 for (HandleMap::iterator i = handles_to_close_.begin();
126 i != handles_to_close_.end(); ++i) { 127 i != handles_to_close_.end(); ++i) {
127 if (output >= end) 128 if (output >= end)
128 return false; 129 return false;
129 HandleListEntry* list_entry = reinterpret_cast<HandleListEntry*>(output); 130 HandleListEntry* list_entry = reinterpret_cast<HandleListEntry*>(output);
130 output = &list_entry->handle_type[0]; 131 output = &list_entry->handle_type[0];
131 132
132 // Copy the typename and set the offset and count. 133 // Copy the typename and set the offset and count.
133 i->first._Copy_s(output, i->first.size(), i->first.size()); 134 i->first._Copy_s(output, i->first.size(), i->first.size());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 194
194 if (NT_SUCCESS(result) && name->Buffer && name->Length) 195 if (NT_SUCCESS(result) && name->Buffer && name->Length)
195 handle_name->assign(name->Buffer, name->Length / sizeof(wchar_t)); 196 handle_name->assign(name->Buffer, name->Length / sizeof(wchar_t));
196 else 197 else
197 handle_name->clear(); 198 handle_name->clear();
198 199
199 return NT_SUCCESS(result); 200 return NT_SUCCESS(result);
200 } 201 }
201 202
202 } // namespace sandbox 203 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/handle_closer.h ('k') | sandbox/win/src/handle_closer_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698