| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Dispatcher and registry for Chrome Extension APIs. | 5 // Dispatcher and registry for Chrome Extension APIs. |
| 6 | 6 |
| 7 #ifndef CEEE_IE_BROKER_API_DISPATCHER_H_ | 7 #ifndef CEEE_IE_BROKER_API_DISPATCHER_H_ |
| 8 #define CEEE_IE_BROKER_API_DISPATCHER_H_ | 8 #define CEEE_IE_BROKER_API_DISPATCHER_H_ |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 }; | 300 }; |
| 301 | 301 |
| 302 // Convenience InvocationFactory implementation. | 302 // Convenience InvocationFactory implementation. |
| 303 template <class InvocationType> | 303 template <class InvocationType> |
| 304 ApiDispatcher::Invocation* NewApiInvocation() { | 304 ApiDispatcher::Invocation* NewApiInvocation() { |
| 305 return new InvocationType(); | 305 return new InvocationType(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 // A singleton that initializes and keeps the ApiDispatcher used by production | 308 // A singleton that initializes and keeps the ApiDispatcher used by production |
| 309 // code. | 309 // code. |
| 310 class ProductionApiDispatcher : public ApiDispatcher, | 310 class ProductionApiDispatcher : public ApiDispatcher { |
| 311 public Singleton<ProductionApiDispatcher> { | 311 public: |
| 312 static ProductionApiDispatcher* GetInstance(); |
| 313 |
| 312 private: | 314 private: |
| 313 // This ensures no construction is possible outside of the class itself. | 315 // This ensures no construction is possible outside of the class itself. |
| 314 friend struct DefaultSingletonTraits<ProductionApiDispatcher>; | 316 friend struct DefaultSingletonTraits<ProductionApiDispatcher>; |
| 315 DISALLOW_IMPLICIT_CONSTRUCTORS(ProductionApiDispatcher); | 317 DISALLOW_IMPLICIT_CONSTRUCTORS(ProductionApiDispatcher); |
| 316 }; | 318 }; |
| 317 | 319 |
| 318 // A convenience class that can be derived from by API function classes instead | 320 // A convenience class that can be derived from by API function classes instead |
| 319 // of ApiDispatcher::Invocation. Mainly benefits ease of testing, so that we | 321 // of ApiDispatcher::Invocation. Mainly benefits ease of testing, so that we |
| 320 // can specify a mocked result object. | 322 // can specify a mocked result object. |
| 321 template<class ResultType = ApiDispatcher::InvocationResult> | 323 template<class ResultType = ApiDispatcher::InvocationResult> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 virtual void CallRealPostError(const std::string& error) { | 398 virtual void CallRealPostError(const std::string& error) { |
| 397 InvocationBase::PostError(error); | 399 InvocationBase::PostError(error); |
| 398 } | 400 } |
| 399 | 401 |
| 400 scoped_ptr<ListValue> result_accumulator_; | 402 scoped_ptr<ListValue> result_accumulator_; |
| 401 std::list<std::string> error_accumulator_; | 403 std::list<std::string> error_accumulator_; |
| 402 }; | 404 }; |
| 403 | 405 |
| 404 | 406 |
| 405 #endif // CEEE_IE_BROKER_API_DISPATCHER_H_ | 407 #endif // CEEE_IE_BROKER_API_DISPATCHER_H_ |
| OLD | NEW |