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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.h

Issue 8437002: Move BrowserThread to content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: A few updates. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ 5 #ifndef CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_
6 #define CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ 6 #define CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 28 matching lines...) Expand all
39 // because once we've constructed a BrowserThemePack through the 39 // because once we've constructed a BrowserThemePack through the
40 // BuildFromExtension() interface, we WriteToDisk() on a thread other than the 40 // BuildFromExtension() interface, we WriteToDisk() on a thread other than the
41 // UI thread that consumes a BrowserThemePack. There is no locking; thread 41 // UI thread that consumes a BrowserThemePack. There is no locking; thread
42 // safety between the writing thread and the UI thread is ensured by having the 42 // safety between the writing thread and the UI thread is ensured by having the
43 // data be immutable. 43 // data be immutable.
44 // 44 //
45 // BrowserThemePacks are always deleted on the file thread because in the 45 // BrowserThemePacks are always deleted on the file thread because in the
46 // common case, they are backed by mmapped data and the unmmapping operation 46 // common case, they are backed by mmapped data and the unmmapping operation
47 // will trip our IO on the UI thread detector. 47 // will trip our IO on the UI thread detector.
48 class BrowserThemePack : public base::RefCountedThreadSafe< 48 class BrowserThemePack : public base::RefCountedThreadSafe<
49 BrowserThemePack, BrowserThread::DeleteOnFileThread> { 49 BrowserThemePack, content::BrowserThread::DeleteOnFileThread> {
50 public: 50 public:
51 // Builds the theme pack from all data from |extension|. This is often done 51 // Builds the theme pack from all data from |extension|. This is often done
52 // on a separate thread as it takes so long. This can fail and return NULL in 52 // on a separate thread as it takes so long. This can fail and return NULL in
53 // the case where the theme has invalid data. 53 // the case where the theme has invalid data.
54 static BrowserThemePack* BuildFromExtension(const Extension* extension); 54 static BrowserThemePack* BuildFromExtension(const Extension* extension);
55 55
56 // Builds the theme pack from a previously performed WriteToDisk(). This 56 // Builds the theme pack from a previously performed WriteToDisk(). This
57 // operation should be relatively fast, as it should be an mmap() and some 57 // operation should be relatively fast, as it should be an mmap() and some
58 // pointer swizzling. Returns NULL on any error attempting to read |path|. 58 // pointer swizzling. Returns NULL on any error attempting to read |path|.
59 static scoped_refptr<BrowserThemePack> BuildFromDataPack( 59 static scoped_refptr<BrowserThemePack> BuildFromDataPack(
(...skipping 24 matching lines...) Expand all
84 const gfx::Image* GetImageNamed(int id) const; 84 const gfx::Image* GetImageNamed(int id) const;
85 85
86 // Returns the raw PNG encoded data for IDR_THEME_NTP_*. This method is only 86 // Returns the raw PNG encoded data for IDR_THEME_NTP_*. This method is only
87 // supposed to work for the NTP attribution and background resources. 87 // supposed to work for the NTP attribution and background resources.
88 RefCountedMemory* GetRawData(int id) const; 88 RefCountedMemory* GetRawData(int id) const;
89 89
90 // Whether this theme provides an image for |id|. 90 // Whether this theme provides an image for |id|.
91 bool HasCustomImage(int id) const; 91 bool HasCustomImage(int id) const;
92 92
93 private: 93 private:
94 friend struct BrowserThread::DeleteOnThread<BrowserThread::FILE>; 94 friend struct content::BrowserThread::DeleteOnThread<
95 content::BrowserThread::FILE>;
95 friend class DeleteTask<BrowserThemePack>; 96 friend class DeleteTask<BrowserThemePack>;
96 friend class BrowserThemePackTest; 97 friend class BrowserThemePackTest;
97 98
98 // Cached images. We cache all retrieved and generated bitmaps and keep 99 // Cached images. We cache all retrieved and generated bitmaps and keep
99 // track of the pointers. We own these and will delete them when we're done 100 // track of the pointers. We own these and will delete them when we're done
100 // using them. 101 // using them.
101 typedef std::map<int, const gfx::Image*> ImageCache; 102 typedef std::map<int, const gfx::Image*> ImageCache;
102 103
103 // The raw PNG memory associated with a certain id. 104 // The raw PNG memory associated with a certain id.
104 typedef std::map<int, scoped_refptr<RefCountedMemory> > RawImages; 105 typedef std::map<int, scoped_refptr<RefCountedMemory> > RawImages;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // in |image_memory_| that are in |prepared_images_| or vice versa. 234 // in |image_memory_| that are in |prepared_images_| or vice versa.
234 ImageCache prepared_images_; 235 ImageCache prepared_images_;
235 236
236 // Loaded images. These are loaded from |image_memory_| or the |data_pack_|. 237 // Loaded images. These are loaded from |image_memory_| or the |data_pack_|.
237 mutable ImageCache loaded_images_; 238 mutable ImageCache loaded_images_;
238 239
239 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); 240 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack);
240 }; 241 };
241 242
242 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ 243 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager_resource_providers.cc ('k') | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698