Chromium Code Reviews| Index: cc/base/switches.cc | 
| diff --git a/cc/base/switches.cc b/cc/base/switches.cc | 
| index be4a2c55adfbcb22214a0a92439f59da8fd112e2..5dbf26cbf86ef8003624c43db301118cd03b5e40 100644 | 
| --- a/cc/base/switches.cc | 
| +++ b/cc/base/switches.cc | 
| @@ -151,51 +151,94 @@ const char kDisable4444Textures[] = "disable-4444-textures"; | 
| const char kDisableCompositorTouchHitTesting[] = | 
| "disable-compositor-touch-hit-testing"; | 
| -bool IsLCDTextEnabled() { | 
| - const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 
| - if (command_line->HasSwitch(cc::switches::kDisableLCDText)) | 
| - return false; | 
| - else if (command_line->HasSwitch(cc::switches::kEnableLCDText)) | 
| - return true; | 
| +class CCSwitchHandler { | 
| 
 
danakj
2013/11/13 19:37:40
you're already in the cc:: namespace. How about ju
 
 | 
| + public: | 
| + static bool isImplSidePaintingEnabled(); | 
| 
 
danakj
2013/11/13 19:37:40
IsImplSidePaintingEnabled <- capitalized
for all
 
 | 
| + static bool isMapImageEnabled(); | 
| + static bool isLCDTextEnabled(); | 
| + | 
| + private: | 
| + static void initializeCCSwitchesIfRequired(); | 
| + | 
| + private: | 
| + static bool s_has_initialized_switches_; | 
| 
 
danakj
2013/11/13 19:37:40
no trailing _ on static variables. they are not in
 
 | 
| + static bool s_impl_side_painting_enabled_; | 
| + static bool s_map_image_enabled_; | 
| + static bool s_lcd_text_enabled_; | 
| +}; | 
| + | 
| +bool CCSwitchHandler::isImplSidePaintingEnabled() { | 
| + initializeCCSwitchesIfRequired(); | 
| + return s_impl_side_painting_enabled_; | 
| +} | 
| -#if defined(OS_ANDROID) | 
| - return false; | 
| -#else | 
| - return true; | 
| -#endif | 
| +bool CCSwitchHandler::isMapImageEnabled() { | 
| + initializeCCSwitchesIfRequired(); | 
| + return s_map_image_enabled_; | 
| } | 
| -namespace { | 
| -bool CheckImplSidePaintingStatus() { | 
| - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 
| +bool CCSwitchHandler::isLCDTextEnabled() { | 
| + initializeCCSwitchesIfRequired(); | 
| + return s_lcd_text_enabled_; | 
| +} | 
| + | 
| +void CCSwitchHandler::initializeCCSwitchesIfRequired() { | 
| + if (s_has_initialized_switches_) | 
| + return; | 
| - if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) | 
| - return false; | 
| - else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) | 
| - return true; | 
| + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 
| + // Impl-side painting. | 
| + if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) { | 
| + s_impl_side_painting_enabled_ = false; | 
| + } else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) { | 
| + s_impl_side_painting_enabled_ = true; | 
| + } else { | 
| +#if defined(OS_ANDROID) | 
| + s_impl_side_painting_enabled_ = true; | 
| +#else | 
| + s_impl_side_painting_enabled_ = false; | 
| +#endif | 
| + } | 
| + // Map-Image. | 
| + if (command_line.HasSwitch(cc::switches::kDisableMapImage)) | 
| + s_map_image_enabled_ = false; | 
| + else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) | 
| + s_map_image_enabled_ = true; | 
| + else | 
| + s_map_image_enabled_ = false; | 
| + | 
| + // LCD-Text. | 
| + if (command_line.HasSwitch(cc::switches::kDisableLCDText)) { | 
| + s_lcd_text_enabled_ = false; | 
| + } else if (command_line.HasSwitch(cc::switches::kEnableLCDText)) { | 
| + s_lcd_text_enabled_ = true; | 
| + } else { | 
| #if defined(OS_ANDROID) | 
| - return true; | 
| + s_lcd_text_enabled_ = false; | 
| #else | 
| - return false; | 
| + s_lcd_text_enabled_ = true; | 
| #endif | 
| + } | 
| + | 
| + s_has_initialized_switches_ = true; | 
| } | 
| -} // namespace | 
| + | 
| +bool CCSwitchHandler::s_has_initialized_switches_ = false; | 
| +bool CCSwitchHandler::s_impl_side_painting_enabled_ = false; | 
| +bool CCSwitchHandler::s_map_image_enabled_ = false; | 
| +bool CCSwitchHandler::s_lcd_text_enabled_ = false; | 
| bool IsImplSidePaintingEnabled() { | 
| - static bool enabled = CheckImplSidePaintingStatus(); | 
| - return enabled; | 
| + return CCSwitchHandler::isImplSidePaintingEnabled(); | 
| } | 
| bool IsMapImageEnabled() { | 
| - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 
| - | 
| - if (command_line.HasSwitch(cc::switches::kDisableMapImage)) | 
| - return false; | 
| - else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) | 
| - return true; | 
| + return CCSwitchHandler::isMapImageEnabled(); | 
| +} | 
| - return false; | 
| +bool IsLCDTextEnabled() { | 
| + return CCSwitchHandler::isLCDTextEnabled(); | 
| } | 
| } // namespace switches |