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

Unified Diff: chrome/app/prefetch_argument_win.cc

Issue 1612663002: Use a valid /prefetch argument when launching a process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bit
Patch Set: self-review Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/app/prefetch_argument_win.cc
diff --git a/chrome/app/prefetch_argument_win.cc b/chrome/app/prefetch_argument_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..31f916517ccf5e1287c9899cb9486af3656999ce
--- /dev/null
+++ b/chrome/app/prefetch_argument_win.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/macros.h"
+#include "base/strings/string16.h"
+#include "base/strings/string_util.h"
+
+bool HasValidWindowsPrefetchArgument(const base::CommandLine& command_line) {
+ const base::char16 kPrefetchArgumentPrefix[] = L"/prefetch:";
+ const size_t kPrefetchArgumentSize = arraysize(kPrefetchArgumentPrefix);
gab 2016/01/26 21:40:26 arraysize() is a compile-time constant, no need to
fdoray 2016/01/27 20:12:19 Done.
+
+ // Check if |command_line| contains an argument "/prefetch:#" where # is
+ // [1, 8].
+ for (const auto& arg : command_line.argv()) {
+ if (arg.size() == kPrefetchArgumentSize &&
+ base::StartsWith(arg, kPrefetchArgumentPrefix,
+ base::CompareCase::SENSITIVE) &&
+ arg[kPrefetchArgumentSize - 1] >= L'1' &&
+ arg[kPrefetchArgumentSize - 1] <= L'8') {
+ return true;
+ }
+ }
+ return false;
+}

Powered by Google App Engine
This is Rietveld 408576698