OLD | NEW |
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_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 | 12 |
| 13 class ExternalExtensionProviderImpl; |
| 14 |
| 15 namespace base { |
13 class DictionaryValue; | 16 class DictionaryValue; |
14 class ExternalExtensionProviderImpl; | 17 } |
15 | 18 |
16 // Base class for gathering a list of external extensions. Subclasses | 19 // Base class for gathering a list of external extensions. Subclasses |
17 // implement loading from registry, JSON file, policy. | 20 // implement loading from registry, JSON file, policy. |
18 // Instances are owned by ExternalExtensionProviderImpl objects. | 21 // Instances are owned by ExternalExtensionProviderImpl objects. |
19 // Instances are created on the UI thread and expect public method calls from | 22 // Instances are created on the UI thread and expect public method calls from |
20 // the UI thread. Some subclasses introduce new methods that are executed on the | 23 // the UI thread. Some subclasses introduce new methods that are executed on the |
21 // FILE thread. | 24 // FILE thread. |
22 // The sequence of loading the extension list: | 25 // The sequence of loading the extension list: |
23 // 1.) StartLoading() - checks if a loading task is already running | 26 // 1.) StartLoading() - checks if a loading task is already running |
24 // 2.) Load() - implemented in subclasses | 27 // 2.) Load() - implemented in subclasses |
(...skipping 30 matching lines...) Expand all Loading... |
55 // Notifies the provider that the list of extensions has been loaded. | 58 // Notifies the provider that the list of extensions has been loaded. |
56 void LoadFinished(); | 59 void LoadFinished(); |
57 | 60 |
58 // Used for passing the list of extensions from the method that loads them | 61 // Used for passing the list of extensions from the method that loads them |
59 // to |LoadFinished|. To ensure thread safety, the rules are the following: | 62 // to |LoadFinished|. To ensure thread safety, the rules are the following: |
60 // if this value is written on another thread than the UI, then it should | 63 // if this value is written on another thread than the UI, then it should |
61 // only be written in a task that was posted from |StartLoading|. After that, | 64 // only be written in a task that was posted from |StartLoading|. After that, |
62 // this task should invoke |LoadFinished| with a PostTask. This scheme of | 65 // this task should invoke |LoadFinished| with a PostTask. This scheme of |
63 // posting tasks will avoid concurrent access and imply the necessary memory | 66 // posting tasks will avoid concurrent access and imply the necessary memory |
64 // barriers. | 67 // barriers. |
65 scoped_ptr<DictionaryValue> prefs_; | 68 scoped_ptr<base::DictionaryValue> prefs_; |
66 | 69 |
67 private: | 70 private: |
68 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; | 71 friend class base::RefCountedThreadSafe<ExternalExtensionLoader>; |
69 | 72 |
70 ExternalExtensionProviderImpl* owner_; // weak | 73 ExternalExtensionProviderImpl* owner_; // weak |
71 | 74 |
72 // Set to true if loading the extensions is already running. New requests | 75 // Set to true if loading the extensions is already running. New requests |
73 // are ignored while this is set true. | 76 // are ignored while this is set true. |
74 bool running_; | 77 bool running_; |
75 | 78 |
76 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionLoader); | 79 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionLoader); |
77 }; | 80 }; |
78 | 81 |
79 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ | 82 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_LOADER_H_ |
OLD | NEW |