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

Side by Side Diff: extensions/browser/extension_function.h

Issue 2294943002: [Extensions] Remove SyncExtensionFunction (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | extensions/browser/extension_function.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 6 #define EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // * RespondNow(Error("Warp core breach")) 188 // * RespondNow(Error("Warp core breach"))
189 // * RespondNow(Error("Warp core breach on *", GetURL())) 189 // * RespondNow(Error("Warp core breach on *", GetURL()))
190 // * RespondLater(), then later, 190 // * RespondLater(), then later,
191 // * Respond(NoArguments()) 191 // * Respond(NoArguments())
192 // * ... etc. 192 // * ... etc.
193 // 193 //
194 // 194 //
195 // Callers must call Execute() on the return ResponseAction at some point, 195 // Callers must call Execute() on the return ResponseAction at some point,
196 // exactly once. 196 // exactly once.
197 // 197 //
198 // SyncExtensionFunction and AsyncExtensionFunction implement this in terms 198 // AsyncExtensionFunctions implement this in terms of
199 // of SyncExtensionFunction::RunSync and AsyncExtensionFunction::RunAsync, 199 // AsyncExtensionFunction::RunAsync, but this is deprecated.
200 // but this is deprecated. ExtensionFunction implementations are encouraged 200 // ExtensionFunction implementations are encouraged to just implement Run.
201 // to just implement Run.
202 virtual ResponseAction Run() WARN_UNUSED_RESULT = 0; 201 virtual ResponseAction Run() WARN_UNUSED_RESULT = 0;
203 202
204 // Gets whether quota should be applied to this individual function 203 // Gets whether quota should be applied to this individual function
205 // invocation. This is different to GetQuotaLimitHeuristics which is only 204 // invocation. This is different to GetQuotaLimitHeuristics which is only
206 // invoked once and then cached. 205 // invoked once and then cached.
207 // 206 //
208 // Returns false by default. 207 // Returns false by default.
209 virtual bool ShouldSkipQuotaLimiting() const; 208 virtual bool ShouldSkipQuotaLimiting() const;
210 209
211 // Optionally adds one or multiple QuotaLimitHeuristic instances suitable for 210 // Optionally adds one or multiple QuotaLimitHeuristic instances suitable for
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 654
656 private: 655 private:
657 // If you're hitting a compile error here due to "final" - great! You're 656 // If you're hitting a compile error here due to "final" - great! You're
658 // doing the right thing, you just need to extend UIThreadExtensionFunction 657 // doing the right thing, you just need to extend UIThreadExtensionFunction
659 // instead of AsyncExtensionFunction. 658 // instead of AsyncExtensionFunction.
660 ResponseAction Run() final; 659 ResponseAction Run() final;
661 660
662 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction); 661 DISALLOW_COPY_AND_ASSIGN(AsyncExtensionFunction);
663 }; 662 };
664 663
665 // A SyncExtensionFunction is an ExtensionFunction that runs synchronously
666 // *relative to the browser's UI thread*. Note that this has nothing to do with
667 // running synchronously relative to the extension process. From the extension
668 // process's point of view, the function is still asynchronous.
669 //
670 // This kind of function is convenient for implementing simple APIs that just
671 // need to interact with things on the browser UI thread.
672 class SyncExtensionFunction : public UIThreadExtensionFunction {
673 public:
674 SyncExtensionFunction();
675
676 protected:
677 ~SyncExtensionFunction() override;
678
679 // Deprecated: Override UIThreadExtensionFunction and implement Run() instead.
680 //
681 // SyncExtensionFunctions implement this method. Return true to respond
682 // immediately with success, false to respond immediately with an error.
683 virtual bool RunSync() = 0;
684
685 // ValidationFailure override to match RunSync().
686 static bool ValidationFailure(SyncExtensionFunction* function);
687
688 private:
689 // If you're hitting a compile error here due to "final" - great! You're
690 // doing the right thing, you just need to extend UIThreadExtensionFunction
691 // instead of SyncExtensionFunction.
692 ResponseAction Run() final;
693
694 DISALLOW_COPY_AND_ASSIGN(SyncExtensionFunction);
695 };
696
697 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_ 664 #endif // EXTENSIONS_BROWSER_EXTENSION_FUNCTION_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698