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

Side by Side Diff: chrome/browser/extensions/user_script_master.h

Issue 193072: Move StringPiece into the base namespace. It is colliding (Closed)
Patch Set: take 2 Created 11 years, 3 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) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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_USER_SCRIPT_MASTER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/directory_watcher.h" 10 #include "base/directory_watcher.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/shared_memory.h" 13 #include "base/shared_memory.h"
14 #include "chrome/common/extensions/user_script.h" 14 #include "chrome/common/extensions/user_script.h"
15 #include "chrome/common/notification_registrar.h" 15 #include "chrome/common/notification_registrar.h"
16 #include "testing/gtest/include/gtest/gtest_prod.h" 16 #include "testing/gtest/include/gtest/gtest_prod.h"
17 17
18 class MessageLoop; 18 class MessageLoop;
19 namespace base {
19 class StringPiece; 20 class StringPiece;
21 }
20 22
21 // Manages a segment of shared memory that contains the user scripts the user 23 // Manages a segment of shared memory that contains the user scripts the user
22 // has installed. Lives on the UI thread. 24 // has installed. Lives on the UI thread.
23 class UserScriptMaster : public base::RefCounted<UserScriptMaster>, 25 class UserScriptMaster : public base::RefCounted<UserScriptMaster>,
24 public DirectoryWatcher::Delegate, 26 public DirectoryWatcher::Delegate,
25 public NotificationObserver { 27 public NotificationObserver {
26 public: 28 public:
27 // For testability, the constructor takes the MessageLoop to run the 29 // For testability, the constructor takes the MessageLoop to run the
28 // script-reloading worker on as well as the path the scripts live in. 30 // script-reloading worker on as well as the path the scripts live in.
29 // These are normally the file thread and a directory inside the profile. 31 // These are normally the file thread and a directory inside the profile.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // We reload user scripts on the file thread to prevent blocking the UI. 65 // We reload user scripts on the file thread to prevent blocking the UI.
64 // ScriptReloader lives on the file thread and does the reload 66 // ScriptReloader lives on the file thread and does the reload
65 // work, and then sends a message back to its master with a new SharedMemory*. 67 // work, and then sends a message back to its master with a new SharedMemory*.
66 // ScriptReloader is the worker that manages running the script scan 68 // ScriptReloader is the worker that manages running the script scan
67 // on the file thread. It must be created on, and its public API must only be 69 // on the file thread. It must be created on, and its public API must only be
68 // called from, the master's thread. 70 // called from, the master's thread.
69 class ScriptReloader 71 class ScriptReloader
70 : public base::RefCounted<UserScriptMaster::ScriptReloader> { 72 : public base::RefCounted<UserScriptMaster::ScriptReloader> {
71 public: 73 public:
72 // Parses the includes out of |script| and returns them in |includes|. 74 // Parses the includes out of |script| and returns them in |includes|.
73 static bool ParseMetadataHeader(const StringPiece& script_text, 75 static bool ParseMetadataHeader(const base::StringPiece& script_text,
74 UserScript* script); 76 UserScript* script);
75 77
76 static void LoadScriptsFromDirectory(const FilePath& script_dir, 78 static void LoadScriptsFromDirectory(const FilePath& script_dir,
77 UserScriptList* result); 79 UserScriptList* result);
78 80
79 explicit ScriptReloader(UserScriptMaster* master); 81 explicit ScriptReloader(UserScriptMaster* master);
80 82
81 // Start a scan for scripts. 83 // Start a scan for scripts.
82 // Will always send a message to the master upon completion. 84 // Will always send a message to the master upon completion.
83 void StartScan(MessageLoop* work_loop, const FilePath& script_dir, 85 void StartScan(MessageLoop* work_loop, const FilePath& script_dir,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 156
155 // If the script directory is modified while we're rescanning it, we note 157 // If the script directory is modified while we're rescanning it, we note
156 // that we're currently mid-scan and then start over again once the scan 158 // that we're currently mid-scan and then start over again once the scan
157 // finishes. This boolean tracks whether another scan is pending. 159 // finishes. This boolean tracks whether another scan is pending.
158 bool pending_scan_; 160 bool pending_scan_;
159 161
160 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster); 162 DISALLOW_COPY_AND_ASSIGN(UserScriptMaster);
161 }; 163 };
162 164
163 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_ 165 #endif // CHROME_BROWSER_EXTENSIONS_USER_SCRIPT_MASTER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_pref_extension_provider.cc ('k') | chrome/browser/extensions/user_script_master.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698