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

Side by Side Diff: chrome/common/service_process_util.cc

Issue 1548153002: Switch to standard integer types in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « chrome/common/service_process_util.h ('k') | chrome/common/service_process_util_posix.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) 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 "chrome/common/service_process_util.h" 5 #include "chrome/common/service_process_util.h"
6 6
7 #include <stdint.h>
8
7 #include <algorithm> 9 #include <algorithm>
8 10
9 #include "base/base_switches.h" 11 #include "base/base_switches.h"
10 #include "base/command_line.h" 12 #include "base/command_line.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h"
12 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
13 #include "base/path_service.h" 16 #include "base/path_service.h"
14 #include "base/sha1.h" 17 #include "base/sha1.h"
15 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
16 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
19 #include "base/version.h" 22 #include "base/version.h"
23 #include "build/build_config.h"
20 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
23 #include "components/cloud_devices/common/cloud_devices_switches.h" 27 #include "components/cloud_devices/common/cloud_devices_switches.h"
24 #include "components/version_info/version_info.h" 28 #include "components/version_info/version_info.h"
25 #include "content/public/common/content_paths.h" 29 #include "content/public/common/content_paths.h"
26 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
27 #include "google_apis/gaia/gaia_switches.h" 31 #include "google_apis/gaia/gaia_switches.h"
28 #include "ui/base/ui_base_switches.h" 32 #include "ui/base/ui_base_switches.h"
29 33
30 #if !defined(OS_MACOSX) 34 #if !defined(OS_MACOSX)
31 35
32 namespace { 36 namespace {
33 37
34 // This should be more than enough to hold a version string assuming each part 38 // This should be more than enough to hold a version string assuming each part
35 // of the version string is an int64. 39 // of the version string is an int64_t.
36 const uint32 kMaxVersionStringLength = 256; 40 const uint32_t kMaxVersionStringLength = 256;
37 41
38 // The structure that gets written to shared memory. 42 // The structure that gets written to shared memory.
39 struct ServiceProcessSharedData { 43 struct ServiceProcessSharedData {
40 char service_process_version[kMaxVersionStringLength]; 44 char service_process_version[kMaxVersionStringLength];
41 base::ProcessId service_process_pid; 45 base::ProcessId service_process_pid;
42 }; 46 };
43 47
44 // Gets the name of the shared memory used by the service process to write its 48 // Gets the name of the shared memory used by the service process to write its
45 // version. The name is not versioned. 49 // version. The name is not versioned.
46 std::string GetServiceProcessSharedMemName() { 50 std::string GetServiceProcessSharedMemName() {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 << version_info::GetVersionNumber().length() 244 << version_info::GetVersionNumber().length()
241 << " which is longer than" << kMaxVersionStringLength; 245 << " which is longer than" << kMaxVersionStringLength;
242 return false; 246 return false;
243 } 247 }
244 248
245 scoped_ptr<base::SharedMemory> shared_mem_service_data( 249 scoped_ptr<base::SharedMemory> shared_mem_service_data(
246 new base::SharedMemory()); 250 new base::SharedMemory());
247 if (!shared_mem_service_data.get()) 251 if (!shared_mem_service_data.get())
248 return false; 252 return false;
249 253
250 uint32 alloc_size = sizeof(ServiceProcessSharedData); 254 uint32_t alloc_size = sizeof(ServiceProcessSharedData);
251 // TODO(viettrungluu): Named shared memory is deprecated (crbug.com/345734). 255 // TODO(viettrungluu): Named shared memory is deprecated (crbug.com/345734).
252 if (!shared_mem_service_data->CreateNamedDeprecated 256 if (!shared_mem_service_data->CreateNamedDeprecated
253 (GetServiceProcessSharedMemName(), true, alloc_size)) 257 (GetServiceProcessSharedMemName(), true, alloc_size))
254 return false; 258 return false;
255 259
256 if (!shared_mem_service_data->Map(alloc_size)) 260 if (!shared_mem_service_data->Map(alloc_size))
257 return false; 261 return false;
258 262
259 memset(shared_mem_service_data->memory(), 0, alloc_size); 263 memset(shared_mem_service_data->memory(), 0, alloc_size);
260 ServiceProcessSharedData* shared_data = 264 ServiceProcessSharedData* shared_data =
261 reinterpret_cast<ServiceProcessSharedData*>( 265 reinterpret_cast<ServiceProcessSharedData*>(
262 shared_mem_service_data->memory()); 266 shared_mem_service_data->memory());
263 memcpy(shared_data->service_process_version, 267 memcpy(shared_data->service_process_version,
264 version_info::GetVersionNumber().c_str(), 268 version_info::GetVersionNumber().c_str(),
265 version_info::GetVersionNumber().length()); 269 version_info::GetVersionNumber().length());
266 shared_data->service_process_pid = base::GetCurrentProcId(); 270 shared_data->service_process_pid = base::GetCurrentProcId();
267 shared_mem_service_data_.reset(shared_mem_service_data.release()); 271 shared_mem_service_data_.reset(shared_mem_service_data.release());
268 return true; 272 return true;
269 } 273 }
270 274
271 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() { 275 IPC::ChannelHandle ServiceProcessState::GetServiceProcessChannel() {
272 return ::GetServiceProcessChannel(); 276 return ::GetServiceProcessChannel();
273 } 277 }
274 278
275 #endif // !OS_MACOSX 279 #endif // !OS_MACOSX
OLDNEW
« no previous file with comments | « chrome/common/service_process_util.h ('k') | chrome/common/service_process_util_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698