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

Side by Side Diff: chrome/browser/chrome_process_finder_win.cc

Issue 1255073002: clang/win: Fix most -Wunused-function warnings in Chromium code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mac Created 5 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/chrome_process_finder_win.h" 5 #include "chrome/browser/chrome_process_finder_win.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/process/process.h" 14 #include "base/process/process.h"
15 #include "base/process/process_info.h" 15 #include "base/process/process_info.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/win/message_window.h" 19 #include "base/win/message_window.h"
20 #include "base/win/metro.h"
21 #include "base/win/scoped_handle.h" 20 #include "base/win/scoped_handle.h"
22 #include "base/win/win_util.h" 21 #include "base/win/win_util.h"
23 #include "base/win/windows_version.h" 22 #include "base/win/windows_version.h"
24 #include "chrome/browser/metro_utils/metro_chrome_win.h"
25 #include "chrome/common/chrome_constants.h" 23 #include "chrome/common/chrome_constants.h"
26 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
27 25
28 26
29 namespace { 27 namespace {
30 28
31 int timeout_in_milliseconds = 20 * 1000; 29 int timeout_in_milliseconds = 20 * 1000;
32 30
33 // The following is copied from net/base/escape.cc. We don't want to depend on
34 // net here because this gets compiled into chrome.exe to facilitate
35 // fast-rendezvous (see https://codereview.chromium.org/14617003/).
36
37 // TODO(koz): Move these functions out of net/base/escape.cc into base/escape.cc
38 // so we can depend on it directly.
39
40 // BEGIN COPY from net/base/escape.cc
41
42 // A fast bit-vector map for ascii characters.
43 //
44 // Internally stores 256 bits in an array of 8 ints.
45 // Does quick bit-flicking to lookup needed characters.
46 struct Charmap {
47 bool Contains(unsigned char c) const {
48 return ((map[c >> 5] & (1 << (c & 31))) != 0);
49 }
50
51 uint32 map[8];
52 };
53
54 const char kHexString[] = "0123456789ABCDEF";
55 inline char IntToHex(int i) {
56 DCHECK_GE(i, 0) << i << " not a hex value";
57 DCHECK_LE(i, 15) << i << " not a hex value";
58 return kHexString[i];
59 }
60
61 // Given text to escape and a Charmap defining which values to escape,
62 // return an escaped string. If use_plus is true, spaces are converted
63 // to +, otherwise, if spaces are in the charmap, they are converted to
64 // %20.
65 std::string Escape(const std::string& text, const Charmap& charmap,
66 bool use_plus) {
67 std::string escaped;
68 escaped.reserve(text.length() * 3);
69 for (unsigned int i = 0; i < text.length(); ++i) {
70 unsigned char c = static_cast<unsigned char>(text[i]);
71 if (use_plus && ' ' == c) {
72 escaped.push_back('+');
73 } else if (charmap.Contains(c)) {
74 escaped.push_back('%');
75 escaped.push_back(IntToHex(c >> 4));
76 escaped.push_back(IntToHex(c & 0xf));
77 } else {
78 escaped.push_back(c);
79 }
80 }
81 return escaped;
82 }
83
84 // Everything except alphanumerics and !'()*-._~
85 // See RFC 2396 for the list of reserved characters.
86 static const Charmap kQueryCharmap = {{
87 0xffffffffL, 0xfc00987dL, 0x78000001L, 0xb8000001L,
88 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL
89 }};
90
91 std::string EscapeQueryParamValue(const std::string& text, bool use_plus) {
92 return Escape(text, kQueryCharmap, use_plus);
93 }
94
95 // END COPY from net/base/escape.cc
96
97 } // namespace 31 } // namespace
98 32
99 namespace chrome { 33 namespace chrome {
100 34
101 HWND FindRunningChromeWindow(const base::FilePath& user_data_dir) { 35 HWND FindRunningChromeWindow(const base::FilePath& user_data_dir) {
102 return base::win::MessageWindow::FindWindow(user_data_dir.value()); 36 return base::win::MessageWindow::FindWindow(user_data_dir.value());
103 } 37 }
104 38
105 NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window, 39 NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window,
106 bool fast_start) { 40 bool fast_start) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 88 }
155 89
156 base::TimeDelta SetNotificationTimeoutForTesting(base::TimeDelta new_timeout) { 90 base::TimeDelta SetNotificationTimeoutForTesting(base::TimeDelta new_timeout) {
157 base::TimeDelta old_timeout = 91 base::TimeDelta old_timeout =
158 base::TimeDelta::FromMilliseconds(timeout_in_milliseconds); 92 base::TimeDelta::FromMilliseconds(timeout_in_milliseconds);
159 timeout_in_milliseconds = new_timeout.InMilliseconds(); 93 timeout_in_milliseconds = new_timeout.InMilliseconds();
160 return old_timeout; 94 return old_timeout;
161 } 95 }
162 96
163 } // namespace chrome 97 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698