OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ipc/ipc_channel_win.h" | 5 #include "ipc/ipc_channel_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // static | 224 // static |
225 const base::string16 ChannelWin::PipeName( | 225 const base::string16 ChannelWin::PipeName( |
226 const std::string& channel_id, int32* secret) { | 226 const std::string& channel_id, int32* secret) { |
227 std::string name("\\\\.\\pipe\\chrome."); | 227 std::string name("\\\\.\\pipe\\chrome."); |
228 | 228 |
229 // Prevent the shared secret from ending up in the pipe name. | 229 // Prevent the shared secret from ending up in the pipe name. |
230 size_t index = channel_id.find_first_of('\\'); | 230 size_t index = channel_id.find_first_of('\\'); |
231 if (index != std::string::npos) { | 231 if (index != std::string::npos) { |
232 if (secret) // Retrieve the secret if asked for. | 232 if (secret) // Retrieve the secret if asked for. |
233 base::StringToInt(channel_id.substr(index + 1), secret); | 233 base::StringToInt(channel_id.substr(index + 1), secret); |
234 return base::ASCIIToWide(name.append(channel_id.substr(0, index - 1))); | 234 return base::ASCIIToUTF16(name.append(channel_id.substr(0, index - 1))); |
235 } | 235 } |
236 | 236 |
237 // This case is here to support predictable named pipes in tests. | 237 // This case is here to support predictable named pipes in tests. |
238 if (secret) | 238 if (secret) |
239 *secret = 0; | 239 *secret = 0; |
240 return base::ASCIIToWide(name.append(channel_id)); | 240 return base::ASCIIToUTF16(name.append(channel_id)); |
241 } | 241 } |
242 | 242 |
243 bool ChannelWin::CreatePipe(const IPC::ChannelHandle &channel_handle, | 243 bool ChannelWin::CreatePipe(const IPC::ChannelHandle &channel_handle, |
244 Mode mode) { | 244 Mode mode) { |
245 DCHECK(!pipe_.IsValid()); | 245 DCHECK(!pipe_.IsValid()); |
246 base::string16 pipe_name; | 246 base::string16 pipe_name; |
247 // If we already have a valid pipe for channel just copy it. | 247 // If we already have a valid pipe for channel just copy it. |
248 if (channel_handle.pipe.handle) { | 248 if (channel_handle.pipe.handle) { |
249 // TODO(rvargas) crbug.com/415294: ChannelHandle should either go away in | 249 // TODO(rvargas) crbug.com/415294: ChannelHandle should either go away in |
250 // favor of two independent entities (name/file), or it should be a move- | 250 // favor of two independent entities (name/file), or it should be a move- |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 int secret; | 560 int secret; |
561 do { // Guarantee we get a non-zero value. | 561 do { // Guarantee we get a non-zero value. |
562 secret = base::RandInt(0, std::numeric_limits<int>::max()); | 562 secret = base::RandInt(0, std::numeric_limits<int>::max()); |
563 } while (secret == 0); | 563 } while (secret == 0); |
564 | 564 |
565 id.append(GenerateUniqueRandomChannelID()); | 565 id.append(GenerateUniqueRandomChannelID()); |
566 return id.append(base::StringPrintf("\\%d", secret)); | 566 return id.append(base::StringPrintf("\\%d", secret)); |
567 } | 567 } |
568 | 568 |
569 } // namespace IPC | 569 } // namespace IPC |
OLD | NEW |