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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// Copyright (c) 2010 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.
//
// Funnel of Chrome Extension Events from whereever through the Broker.
#include "ceee/ie/plugin/bho/webrequest_events_funnel.h"
#include "base/logging.h"
#include "base/values.h"
#include "chrome/browser/extensions/extension_webrequest_api_constants.h"
namespace keys = extension_webrequest_api_constants;
namespace {
double MilliSecondsFromTime(const base::Time& time) {
return base::Time::kMillisecondsPerSecond * time.ToDoubleT();
}
} // namespace
HRESULT WebRequestEventsFunnel::OnBeforeRedirect(int request_id,
const wchar_t* url,
DWORD status_code,
const wchar_t* redirect_url,
const base::Time& time_stamp) {
DictionaryValue args;
args.SetInteger(keys::kRequestIdKey, request_id);
args.SetString(keys::kUrlKey, url);
args.SetInteger(keys::kStatusCodeKey, status_code);
args.SetString(keys::kRedirectUrlKey, redirect_url);
args.SetReal(keys::kTimeStampKey, MilliSecondsFromTime(time_stamp));
return SendEvent(keys::kOnBeforeRedirect, args);
}
HRESULT WebRequestEventsFunnel::OnBeforeRequest(int request_id,
const wchar_t* url,
const char* method,
CeeeWindowHandle tab_handle,
const char* type,
const base::Time& time_stamp) {
DictionaryValue args;
args.SetInteger(keys::kRequestIdKey, request_id);
args.SetString(keys::kUrlKey, url);
args.SetString(keys::kMethodKey, method);
args.SetInteger(keys::kTabIdKey, static_cast<int>(tab_handle));
args.SetString(keys::kTypeKey, type);
args.SetReal(keys::kTimeStampKey, MilliSecondsFromTime(time_stamp));
return SendEvent(keys::kOnBeforeRequest, args);
}
HRESULT WebRequestEventsFunnel::OnCompleted(int request_id,
const wchar_t* url,
DWORD status_code,
const base::Time& time_stamp) {
DictionaryValue args;
args.SetInteger(keys::kRequestIdKey, request_id);
args.SetString(keys::kUrlKey, url);
args.SetInteger(keys::kStatusCodeKey, status_code);
args.SetReal(keys::kTimeStampKey, MilliSecondsFromTime(time_stamp));
return SendEvent(keys::kOnCompleted, args);
}
HRESULT WebRequestEventsFunnel::OnErrorOccurred(int request_id,
const wchar_t* url,
const wchar_t* error,
const base::Time& time_stamp) {
DictionaryValue args;
args.SetInteger(keys::kRequestIdKey, request_id);
args.SetString(keys::kUrlKey, url);
args.SetString(keys::kErrorKey, error);
args.SetReal(keys::kTimeStampKey, MilliSecondsFromTime(time_stamp));
return SendEvent(keys::kOnErrorOccurred, args);
}
HRESULT WebRequestEventsFunnel::OnHeadersReceived(
int request_id,
const wchar_t* url,
DWORD status_code,
const base::Time& time_stamp) {
DictionaryValue args;
args.SetInteger(keys::kRequestIdKey, request_id);
args.SetString(keys::kUrlKey, url);
args.SetInteger(keys::kStatusCodeKey, status_code);
args.SetReal(keys::kTimeStampKey, MilliSecondsFromTime(time_stamp));
return SendEvent(keys::kOnHeadersReceived, args);
}
HRESULT WebRequestEventsFunnel::OnRequestSent(int request_id,
const wchar_t* url,
const char* ip,
const base::Time& time_stamp) {
DictionaryValue args;
args.SetInteger(keys::kRequestIdKey, request_id);
args.SetString(keys::kUrlKey, url);
args.SetString(keys::kIpKey, ip);
args.SetReal(keys::kTimeStampKey, MilliSecondsFromTime(time_stamp));
return SendEvent(keys::kOnRequestSent, args);
}
|