summaryrefslogtreecommitdiffstats
path: root/cc/test/test_webkit_platform.cc
blob: 403ba6130142b94716218a2b57fe9838e3b94915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/test/test_webkit_platform.h"

namespace cc {

TestWebKitPlatform::TestWebKitPlatform() {
}

TestWebKitPlatform::~TestWebKitPlatform() {
}

WebKit::WebCompositorSupport* TestWebKitPlatform::compositorSupport() {
  return &compositor_support_;
}

void TestWebKitPlatform::cryptographicallyRandomValues(
      unsigned char* buffer, size_t length) {
  base::RandBytes(buffer, length);
}

WebKit::WebThread* TestWebKitPlatform::createThread(const char* name) {
  return new webkit_glue::WebThreadImpl(name);
}

WebKit::WebThread* TestWebKitPlatform::currentThread() {
  webkit_glue::WebThreadImplForMessageLoop* thread =
      static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get());
  if (thread)
    return (thread);

  scoped_refptr<base::MessageLoopProxy> message_loop =
      base::MessageLoopProxy::current();
  if (!message_loop)
    return NULL;

  thread = new WebThreadImplForMessageLoop(message_loop);
  current_thread_slot_.Set(thread);
  return thread;
}

double TestWebKitPlatform::currentTime() {
  return base::Time::Now().ToDoubleT();
}

double TestWebKitPlatform::monotonicallyIncreasingTime() {
  return base::TimeTicks::Now().ToInternalValue() /
      static_cast<double>(base::Time::kMicrosecondsPerSecond);
}

}