Index: cc/base/switches.cc |
diff --git a/cc/base/switches.cc b/cc/base/switches.cc |
old mode 100644 |
new mode 100755 |
index ddba9cbd4449b52cb8edd870a77dccc45faafb35..3e4354806a6e1cf2c7be8efe569498a8c65e6863 |
--- a/cc/base/switches.cc |
+++ b/cc/base/switches.cc |
@@ -5,6 +5,7 @@ |
#include "cc/base/switches.h" |
#include "base/command_line.h" |
+#include "base/strings/string_number_conversions.h" |
namespace cc { |
namespace switches { |
@@ -209,5 +210,29 @@ bool IsMapImageEnabled() { |
return false; |
} |
+size_t CheckNumRasterThreads() { |
reveman
2013/12/27 14:57:13
move this function to anonymous namespace.
sohanjg
2013/12/28 09:15:17
Done.
|
+ const int kMinRasterThreads = 1; |
+ const int kMaxRasterThreads = 64; |
+ const int kDefaultNumRasterThreads = 1; |
+ |
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
+ int num_threads = kDefaultNumRasterThreads; |
+ if (command_line.HasSwitch(switches::kNumRasterThreads)) { |
+ std::string string_value = |
+ command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
+ if (!(base::StringToInt(string_value, &num_threads) && |
+ num_threads >= kMinRasterThreads && num_threads <= kMaxRasterThreads)) { |
reveman
2013/12/27 14:57:13
This is wrong. You're checking the value of num_th
sohanjg
2013/12/28 09:15:17
Done.
|
+ LOG(WARNING) << "Failed to parse switch " << |
+ switches::kNumRasterThreads << ": " << string_value; |
+ num_threads = kDefaultNumRasterThreads; |
+ } |
+ } |
+ return num_threads; |
+} |
+ |
+size_t GetNumRasterThreads() { |
+ static size_t num_raster_threads = CheckNumRasterThreads(); |
+ return num_raster_threads; |
+} |
} // namespace switches |
} // namespace cc |