summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/test_shell_devtools_callargs.h
blob: 3fd76323b1086708f1c1ca21987ae17cb81fff08 (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
// Copyright (c) 2009 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.

#ifndef TEST_SHELL_DEVTOOLS_CALLARGS_H_
#define TEST_SHELL_DEVTOOLS_CALLARGS_H_

#include "base/logging.h"

#include "third_party/WebKit/WebKit/chromium/public/WebDevToolsMessageData.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"

class TestShellDevToolsCallArgs {
 public:
  TestShellDevToolsCallArgs(const WebKit::WebDevToolsMessageData& data)
      : data_(data) {
    ++calls_count_;

    // The same behaiviour as we have in case of IPC.
    for (size_t i = 0; i < data_.arguments.size(); ++i)
      if (data_.arguments[i].isNull())
        data_.arguments[i] = WebKit::WebString::fromUTF8("");
  }

  TestShellDevToolsCallArgs(const TestShellDevToolsCallArgs& args)
      : data_(args.data_) {
    ++calls_count_;
  }

  ~TestShellDevToolsCallArgs() {
    --calls_count_;
    DCHECK(calls_count_ >= 0);
  }

  static int calls_count() { return calls_count_; }

  WebKit::WebDevToolsMessageData data_;

 private:
  static int calls_count_;
};

#endif  // TEST_SHELL_DEVTOOLS_CALLARGS_H_