1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/repeat_controller.h"
11 // The delay before the first and then subsequent repeats. Values taken from
12 // XUL code: http://mxr.mozilla.org/seamonkey/source/layout/xul/base/src/nsRepeatService.cpp#52
13 const int kInitialRepeatDelay
= 250;
14 const int kRepeatDelay
= 50;
16 ///////////////////////////////////////////////////////////////////////////////
17 // RepeatController, public:
19 RepeatController::RepeatController(const base::Closure
& callback
)
20 : callback_(callback
) {
23 RepeatController::~RepeatController() {
26 void RepeatController::Start() {
27 // The first timer is slightly longer than subsequent repeats.
28 timer_
.Start(FROM_HERE
, TimeDelta::FromMilliseconds(kInitialRepeatDelay
),
29 this, &RepeatController::Run
);
32 void RepeatController::Stop() {
36 ///////////////////////////////////////////////////////////////////////////////
37 // RepeatController, private:
39 void RepeatController::Run() {
40 timer_
.Start(FROM_HERE
, TimeDelta::FromMilliseconds(kRepeatDelay
), this,
41 &RepeatController::Run
);