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

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

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop_helpers.h" 15 #include "base/message_loop_helpers.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "ui/gfx/color_utils.h" 18 #include "ui/gfx/color_utils.h"
19 19
20 class FilePath; 20 class FilePath;
21 namespace ui { 21
22 class DataPack;
23 }
24 namespace gfx {
25 class Image;
26 }
27 namespace base { 22 namespace base {
28 class DictionaryValue; 23 class DictionaryValue;
29 class RefCountedMemory; 24 class RefCountedMemory;
30 } 25 }
31 26
27 namespace extensions {
28 class Extensions;
29 }
30
31 namespace gfx {
32 class Image;
33 }
34
35 namespace ui {
36 class DataPack;
37 }
38
32 // An optimized representation of a theme, backed by a mmapped DataPack. 39 // An optimized representation of a theme, backed by a mmapped DataPack.
33 // 40 //
34 // The idea is to pre-process all images (tinting, compositing, etc) at theme 41 // The idea is to pre-process all images (tinting, compositing, etc) at theme
35 // install time, save all the PNG-ified data into an mmappable file so we don't 42 // install time, save all the PNG-ified data into an mmappable file so we don't
36 // suffer multiple file system access times, therefore solving two of the 43 // suffer multiple file system access times, therefore solving two of the
37 // problems with the previous implementation. 44 // problems with the previous implementation.
38 // 45 //
39 // A note on const-ness. All public, non-static methods are const. We do this 46 // A note on const-ness. All public, non-static methods are const. We do this
40 // because once we've constructed a BrowserThemePack through the 47 // because once we've constructed a BrowserThemePack through the
41 // BuildFromExtension() interface, we WriteToDisk() on a thread other than the 48 // BuildFromExtension() interface, we WriteToDisk() on a thread other than the
42 // UI thread that consumes a BrowserThemePack. There is no locking; thread 49 // UI thread that consumes a BrowserThemePack. There is no locking; thread
43 // safety between the writing thread and the UI thread is ensured by having the 50 // safety between the writing thread and the UI thread is ensured by having the
44 // data be immutable. 51 // data be immutable.
45 // 52 //
46 // BrowserThemePacks are always deleted on the file thread because in the 53 // BrowserThemePacks are always deleted on the file thread because in the
47 // common case, they are backed by mmapped data and the unmmapping operation 54 // common case, they are backed by mmapped data and the unmmapping operation
48 // will trip our IO on the UI thread detector. 55 // will trip our IO on the UI thread detector.
49 class BrowserThemePack : public base::RefCountedThreadSafe< 56 class BrowserThemePack : public base::RefCountedThreadSafe<
50 BrowserThemePack, content::BrowserThread::DeleteOnFileThread> { 57 BrowserThemePack, content::BrowserThread::DeleteOnFileThread> {
51 public: 58 public:
52 // Builds the theme pack from all data from |extension|. This is often done 59 // Builds the theme pack from all data from |extension|. This is often done
53 // on a separate thread as it takes so long. This can fail and return NULL in 60 // on a separate thread as it takes so long. This can fail and return NULL in
54 // the case where the theme has invalid data. 61 // the case where the theme has invalid data.
55 static scoped_refptr<BrowserThemePack> BuildFromExtension( 62 static scoped_refptr<BrowserThemePack> BuildFromExtension(
56 const Extension* extension); 63 const extensions::Extension* extension);
57 64
58 // Builds the theme pack from a previously performed WriteToDisk(). This 65 // Builds the theme pack from a previously performed WriteToDisk(). This
59 // operation should be relatively fast, as it should be an mmap() and some 66 // operation should be relatively fast, as it should be an mmap() and some
60 // pointer swizzling. Returns NULL on any error attempting to read |path|. 67 // pointer swizzling. Returns NULL on any error attempting to read |path|.
61 static scoped_refptr<BrowserThemePack> BuildFromDataPack( 68 static scoped_refptr<BrowserThemePack> BuildFromDataPack(
62 FilePath path, const std::string& expected_id); 69 FilePath path, const std::string& expected_id);
63 70
64 // Builds a data pack on disk at |path| for future quick loading by 71 // Builds a data pack on disk at |path| for future quick loading by
65 // BuildFromDataPack(). Often (but not always) called from the file thread; 72 // BuildFromDataPack(). Often (but not always) called from the file thread;
66 // implementation should be threadsafe because neither thread will write to 73 // implementation should be threadsafe because neither thread will write to
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 118
112 // An association between an id and the FilePath that has the image data. 119 // An association between an id and the FilePath that has the image data.
113 typedef std::map<int, FilePath> FilePathMap; 120 typedef std::map<int, FilePath> FilePathMap;
114 121
115 // Default. Everything is empty. 122 // Default. Everything is empty.
116 BrowserThemePack(); 123 BrowserThemePack();
117 124
118 virtual ~BrowserThemePack(); 125 virtual ~BrowserThemePack();
119 126
120 // Builds a header ready to write to disk. 127 // Builds a header ready to write to disk.
121 void BuildHeader(const Extension* extension); 128 void BuildHeader(const extensions::Extension* extension);
122 129
123 // Transforms the JSON tint values into their final versions in the |tints_| 130 // Transforms the JSON tint values into their final versions in the |tints_|
124 // array. 131 // array.
125 void BuildTintsFromJSON(base::DictionaryValue* tints_value); 132 void BuildTintsFromJSON(base::DictionaryValue* tints_value);
126 133
127 // Transforms the JSON color values into their final versions in the 134 // Transforms the JSON color values into their final versions in the
128 // |colors_| array and also fills in unspecified colors based on tint values. 135 // |colors_| array and also fills in unspecified colors based on tint values.
129 void BuildColorsFromJSON(base::DictionaryValue* color_value); 136 void BuildColorsFromJSON(base::DictionaryValue* color_value);
130 137
131 // Implementation details of BuildColorsFromJSON(). 138 // Implementation details of BuildColorsFromJSON().
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // in |image_memory_| that are in |prepared_images_| or vice versa. 243 // in |image_memory_| that are in |prepared_images_| or vice versa.
237 ImageCache prepared_images_; 244 ImageCache prepared_images_;
238 245
239 // Loaded images. These are loaded from |image_memory_| or the |data_pack_|. 246 // Loaded images. These are loaded from |image_memory_| or the |data_pack_|.
240 mutable ImageCache loaded_images_; 247 mutable ImageCache loaded_images_;
241 248
242 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack); 249 DISALLOW_COPY_AND_ASSIGN(BrowserThemePack);
243 }; 250 };
244 251
245 #endif // CHROME_BROWSER_THEMES_BROWSER_THEME_PACK_H_ 252 #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