Chromium Code Reviews| Index: ui/gfx/color_profile_win.cc |
| diff --git a/ui/gfx/color_profile_win.cc b/ui/gfx/color_profile_win.cc |
| index 43ea465795834f735a133d8cb9b8b79c80ea60e9..c4b26b4d226dedb9c0a2a284b53d56b8277b7418 100644 |
| --- a/ui/gfx/color_profile_win.cc |
| +++ b/ui/gfx/color_profile_win.cc |
| @@ -4,12 +4,53 @@ |
| #include "ui/gfx/color_profile.h" |
| +#include <map> |
| #include <windows.h> |
| #include "base/file_util.h" |
| +#include "base/synchronization/lock.h" |
| namespace gfx { |
| +class ColorProfileCache { |
|
sky
2014/05/29 15:31:32
Add description.
|
| + public: |
| + ColorProfileCache() {} |
| + |
| + bool find(const std::wstring& device, std::vector<char>* profile) { |
|
sky
2014/05/29 15:31:32
All your function names should be camelcase, eg Fi
|
| + base::AutoLock lock(lock_); |
| + DeviceColorProfile::const_iterator it = cache_.find(device); |
| + if (it == cache_.end()) |
| + return false; |
| + *profile = it->second; |
| + return true; |
| + } |
| + |
| + void insert(const std::wstring& device, const std::vector<char>& profile) { |
| + base::AutoLock lock(lock_); |
| + cache_[device] = profile; |
| + } |
| + |
| + bool erase(const std::wstring& device) { |
| + base::AutoLock lock(lock_); |
| + DeviceColorProfile::iterator it = cache_.find(device); |
| + if (it == cache_.end()) |
| + return false; |
| + cache_.erase(device); |
| + return true; |
| + } |
| + |
| + void clear() { |
| + base::AutoLock lock(lock_); |
| + cache_.clear(); |
| + } |
| + |
| + private: |
| + typedef std::map<std::wstring, std::vector<char> > DeviceColorProfile; |
| + |
| + DeviceColorProfile cache_; |
| + base::Lock lock_; |
| +}; |
|
sky
2014/05/29 15:31:32
DISALLOW_COPY_AND_ASSIGN.
|
| + |
| bool GetDisplayColorProfile(const gfx::Rect& bounds, |
| std::vector<char>* profile) { |
| if (bounds.IsEmpty()) |