PerformanceWorker.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "PerformanceWorker.h"
  6. #include "WorkerPrivate.h"
  7. namespace mozilla {
  8. namespace dom {
  9. using namespace workers;
  10. PerformanceWorker::PerformanceWorker(WorkerPrivate* aWorkerPrivate)
  11. : mWorkerPrivate(aWorkerPrivate)
  12. {
  13. mWorkerPrivate->AssertIsOnWorkerThread();
  14. }
  15. PerformanceWorker::~PerformanceWorker()
  16. {
  17. mWorkerPrivate->AssertIsOnWorkerThread();
  18. }
  19. void
  20. PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
  21. {
  22. if (mWorkerPrivate->PerformanceLoggingEnabled()) {
  23. nsAutoCString uri;
  24. nsCOMPtr<nsIURI> scriptURI = mWorkerPrivate->GetResolvedScriptURI();
  25. if (!scriptURI || NS_FAILED(scriptURI->GetHost(uri))) {
  26. // If we have no URI, just put in "none".
  27. uri.AssignLiteral("none");
  28. }
  29. Performance::LogEntry(aEntry, uri);
  30. }
  31. Performance::InsertUserEntry(aEntry);
  32. }
  33. TimeStamp
  34. PerformanceWorker::CreationTimeStamp() const
  35. {
  36. return mWorkerPrivate->CreationTimeStamp();
  37. }
  38. DOMHighResTimeStamp
  39. PerformanceWorker::CreationTime() const
  40. {
  41. return mWorkerPrivate->CreationTime();
  42. }
  43. } // dom namespace
  44. } // mozilla namespace