Opera 12.15 Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dochand_module.h 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. **
  3. ** Copyright (C) 1995-2005 Opera Software AS. All rights reserved.
  4. **
  5. ** This file is part of the Opera web browser. It may not be distributed
  6. ** under any circumstances.
  7. */
  8. #ifndef MODULES_DOCHAND_DOCHAND_MODULE_H
  9. #define MODULES_DOCHAND_DOCHAND_MODULE_H
  10. #include "modules/hardcore/opera/module.h"
  11. class WindowManager;
  12. class OperaURL_Generator;
  13. /**
  14. * Class which limits the amount of fraud checks being done after a request fails.
  15. *
  16. * This is to stop DOS-ing the site check server once it comes up again because all
  17. * clients try to hammer it simultaniously. Hence if a request fails we will not try
  18. * another attempt until the time FRAUD_CHECK_MINIMUM_GRACE_PERIOD has expired, and with
  19. * exponential fall off for each successive failed attempt until the grace period is
  20. * FRAUD_CHECK_MAXIMUM_GRACE_PERIOD.
  21. *
  22. * See bug CORE-18851
  23. */
  24. class FraudCheckRequestThrottler
  25. {
  26. public:
  27. FraudCheckRequestThrottler() : m_last_failed_request(0.0), m_grace_period(0) {}
  28. void RequestFailed();
  29. void RequestSucceeded() { m_grace_period = 0; } // Reset grace period
  30. /// Should making a fraud check be allowed now, or are we still in the grace period from a previous failed check
  31. BOOL AllowRequestNow();
  32. private:
  33. double m_last_failed_request; // GetRuntimeMS() time of the last failed request or 0.0 if nothing has ever failed
  34. unsigned m_grace_period; // seconds from one failed request until we can try a new request
  35. };
  36. class DochandModule : public OperaModule
  37. {
  38. public:
  39. DochandModule();
  40. void InitL(const OperaInitInfo& info);
  41. void Destroy();
  42. WindowManager* window_manager;
  43. #ifdef TRUST_RATING
  44. FraudCheckRequestThrottler fraud_request_throttler;
  45. #endif // TRUST_RATING
  46. #ifdef WEBSERVER_SUPPORT
  47. OperaURL_Generator* unitewarningpage_generator;
  48. #endif // WEBSERVER_SUPPORT
  49. };
  50. #define g_windowManager g_opera->dochand_module.window_manager
  51. #define windowManager g_windowManager
  52. #ifdef TRUST_RATING
  53. # define g_fraud_check_request_throttler g_opera->dochand_module.fraud_request_throttler
  54. #endif // TRUST_RATING
  55. #define DOCHAND_MODULE_REQUIRED
  56. #endif // !MODULES_DOCHAND_DOCHAND_MODULE_H