mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Compare commits
1195 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fade53b95 | ||
|
|
4997b2f0c8 | ||
|
|
144febe093 | ||
|
|
8439bff33e | ||
|
|
cac57a77ee | ||
|
|
c82167e9d5 | ||
|
|
10e12ee872 | ||
|
|
20f520fb28 | ||
|
|
fd43a8bf44 | ||
|
|
bd266efefe | ||
|
|
174044c64c | ||
|
|
1f48ecb4be | ||
|
|
ea9bdad924 | ||
|
|
e33296a451 | ||
|
|
e3e90f9cf6 | ||
|
|
386a0a5856 | ||
|
|
40b21a9583 | ||
|
|
ab58b1b17b | ||
|
|
c718a5bee6 | ||
|
|
7538208409 | ||
|
|
f8b673a3ea | ||
|
|
89ab864065 | ||
|
|
7abba8b86d | ||
|
|
34dbad30db | ||
|
|
c166b4abc9 | ||
|
|
e513077eac | ||
|
|
b660522983 | ||
|
|
b070564ec5 | ||
|
|
980cc4b9fe | ||
|
|
213c0280e9 | ||
|
|
be11f21131 | ||
|
|
43fc50a89e | ||
|
|
0255c2e7ac | ||
|
|
a05b959543 | ||
|
|
173a2f4a58 | ||
|
|
5d817b20a6 | ||
|
|
e3a8741563 | ||
|
|
ed38bd3302 | ||
|
|
a787036a8a | ||
|
|
fc20e76d3b | ||
|
|
030272fe4c | ||
|
|
00e9b561f8 | ||
|
|
02fec23bc8 | ||
|
|
323cbdc5ea | ||
|
|
6f44cfcb65 | ||
|
|
da7e19d0ea | ||
|
|
6e05c14db2 | ||
|
|
265a733807 | ||
|
|
6036df047f | ||
|
|
884b582789 | ||
|
|
66105a5417 | ||
|
|
b974438cfc | ||
|
|
1bc1ca15d5 | ||
|
|
e23bf31bf4 | ||
|
|
0a627230ac | ||
|
|
f94ac23e52 | ||
|
|
745a4d6e3b | ||
|
|
29ef97d6b5 | ||
|
|
a231b7ead7 | ||
|
|
e5bc3c9255 | ||
|
|
330534a2e7 | ||
|
|
467a0d6a85 | ||
|
|
2b6f461337 | ||
|
|
abfc029a01 | ||
|
|
ac71a0e9f2 | ||
|
|
cd052ec7c3 | ||
|
|
e44d33d5bf | ||
|
|
6459917c0a | ||
|
|
b90f0048da | ||
|
|
8c6f8dd404 | ||
|
|
af1f40a2d3 | ||
|
|
2cd405baac | ||
|
|
b98eac265a | ||
|
|
701c9470f2 | ||
|
|
889cfcf8d1 | ||
|
|
ebb3c962da | ||
|
|
64a2f681aa | ||
|
|
52888f346f | ||
|
|
9e9ba2c543 | ||
|
|
166eec85e0 | ||
|
|
f6f4ba8317 | ||
|
|
bed7f420aa | ||
|
|
be4085981c | ||
|
|
785713c4cc | ||
|
|
b61c106b6b | ||
|
|
295ea1f715 | ||
|
|
08ae3a44a6 | ||
|
|
5ddeef736a | ||
|
|
446b7d6535 | ||
|
|
a6c00b2ff6 | ||
|
|
69b884d39c | ||
|
|
3acdbac061 | ||
|
|
d470cf8204 | ||
|
|
cbbca050e0 | ||
|
|
69fbadd0bc | ||
|
|
4023fea237 | ||
|
|
5607a4d347 | ||
|
|
8f4a47479c | ||
|
|
02ea88f79f | ||
|
|
ddb0ab8187 | ||
|
|
ed4257c807 | ||
|
|
b7a172fefc | ||
|
|
68e1fcf3a4 | ||
|
|
1f35258023 | ||
|
|
60ce575e53 | ||
|
|
0d166c3c90 | ||
|
|
9b284ec8f7 | ||
|
|
b080705ec8 | ||
|
|
1cdf02815e | ||
|
|
cd3f617171 | ||
|
|
bd57a40256 | ||
|
|
c0a3c897cf | ||
|
|
231701d98b | ||
|
|
a461a89728 | ||
|
|
b95b3e6fd5 | ||
|
|
c4a6797059 | ||
|
|
ebb99fbd58 | ||
|
|
1d7e83336f | ||
|
|
2a19d3dc57 | ||
|
|
810c51026c | ||
|
|
5afde67593 | ||
|
|
3b98dbda79 | ||
|
|
c44aa35bfc | ||
|
|
4ed13d8c47 | ||
|
|
fe24ce3c71 | ||
|
|
cc40cbdd45 | ||
|
|
7c19cb90e1 | ||
|
|
47798d3dbf | ||
|
|
e4bb51f6f6 | ||
|
|
fd7444c7a4 | ||
|
|
c56ae7213e | ||
|
|
cb1830e16c | ||
|
|
39cafe3e6c | ||
|
|
15c7e80e3c | ||
|
|
8e79307a62 | ||
|
|
b0bceecba9 | ||
|
|
b6842f8b80 | ||
|
|
5fe6382906 | ||
|
|
bd1e188c77 | ||
|
|
701fc03f00 | ||
|
|
bc1b856b96 | ||
|
|
c7b30ee80f | ||
|
|
48137b9538 | ||
|
|
5a2cfb6907 | ||
|
|
6354d8daf1 | ||
|
|
aad216bf56 | ||
|
|
3f036edf2d | ||
|
|
32fc106ab0 | ||
|
|
0170f431a0 | ||
|
|
2156c9fd5d | ||
|
|
00118ddcdb | ||
|
|
e7626b2df6 | ||
|
|
8283317cb1 | ||
|
|
271c6f6446 | ||
|
|
311eaf827e | ||
|
|
002f4b5b4a | ||
|
|
17a1fd62ec | ||
|
|
ca636bb96e | ||
|
|
4e3668f93a | ||
|
|
6b13b1c627 | ||
|
|
29381355ef | ||
|
|
7328b9e40d | ||
|
|
b92749a58a | ||
|
|
49a34d9160 | ||
|
|
b5d84c254d | ||
|
|
d666ec5770 | ||
|
|
fe5b0dd668 | ||
|
|
c0e7854782 | ||
|
|
be6642df3f | ||
|
|
ed079792b6 | ||
|
|
0783b4c57d | ||
|
|
b537fc929b | ||
|
|
708d90a6ff | ||
|
|
5065aba1b4 | ||
|
|
65234a6830 | ||
|
|
b67cbc47e3 | ||
|
|
4fe529e2dc | ||
|
|
260dd0ca24 | ||
|
|
dca0435d2f | ||
|
|
62c93f01f4 | ||
|
|
81a0648ee1 | ||
|
|
744a194a6e | ||
|
|
96dc172980 | ||
|
|
f1effba336 | ||
|
|
d10cc16236 | ||
|
|
da1c3179a9 | ||
|
|
2e33954032 | ||
|
|
f60476b848 | ||
|
|
29c21f58e8 | ||
|
|
54a9c26b92 | ||
|
|
6253e69b70 | ||
|
|
8ba22e9e11 | ||
|
|
19ba8b2b8d | ||
|
|
a13b6dc7f6 | ||
|
|
52dac91167 | ||
|
|
526e934a12 | ||
|
|
b8f91c5431 | ||
|
|
5e616b2df0 | ||
|
|
9b06b028dc | ||
|
|
d4cf19db29 | ||
|
|
2c5dd120c7 | ||
|
|
ffea0d9c4a | ||
|
|
8db08e657d | ||
|
|
706193f3d9 | ||
|
|
bfed26c5fc | ||
|
|
71c8b4b2bb | ||
|
|
ec122a9148 | ||
|
|
90775f149f | ||
|
|
f071a4a988 | ||
|
|
cc3d77eec5 | ||
|
|
a79981bf7f | ||
|
|
70471059cf | ||
|
|
5dc3cc13e7 | ||
|
|
da3899d142 | ||
|
|
69fd43f789 | ||
|
|
d3a483ef59 | ||
|
|
bdb070c85c | ||
|
|
57bad703ee | ||
|
|
47fe9f834a | ||
|
|
2f1e782f62 | ||
|
|
2a86a02bdd | ||
|
|
132ac7a180 | ||
|
|
a0446a3c8a | ||
|
|
a02d2ab3e6 | ||
|
|
4ea1b6f293 | ||
|
|
befa827da1 | ||
|
|
0a64bb6f9b | ||
|
|
9fd312ce04 | ||
|
|
468e55e553 | ||
|
|
f1fe098e09 | ||
|
|
5af6227a6f | ||
|
|
0d50d5a8c6 | ||
|
|
a097b62b6e | ||
|
|
ffc703276a | ||
|
|
3592d36808 | ||
|
|
deb4664038 | ||
|
|
9f6995f839 | ||
|
|
784302280b | ||
|
|
7c2bd75f7a | ||
|
|
3507249202 | ||
|
|
5a9b8e2bc4 | ||
|
|
9a45102db0 | ||
|
|
1f55d2e12f | ||
|
|
9dc7653ddc | ||
|
|
e4acacee18 | ||
|
|
206b7b1c95 | ||
|
|
262a93b2f7 | ||
|
|
80c65f25a3 | ||
|
|
2f0b00f8f5 | ||
|
|
be734efe68 | ||
|
|
0dd7dca229 | ||
|
|
5613af8f53 | ||
|
|
a25f89f9e4 | ||
|
|
d6af79e7a6 | ||
|
|
f781ea373f | ||
|
|
738192addf | ||
|
|
2b1922746f | ||
|
|
3b652a9966 | ||
|
|
cf934a20a7 | ||
|
|
a9f1ce090a | ||
|
|
1886f68490 | ||
|
|
53ef570f57 | ||
|
|
d3d465b32e | ||
|
|
2b38e2f793 | ||
|
|
3837f209e1 | ||
|
|
21e01d4889 | ||
|
|
44323082b1 | ||
|
|
1b74ac5124 | ||
|
|
b2274f534d | ||
|
|
3476199bc5 | ||
|
|
6651523d86 | ||
|
|
f594ca3785 | ||
|
|
15caa9858d | ||
|
|
e6a96e2bec | ||
|
|
90aea56de6 | ||
|
|
a2a1b66ea5 | ||
|
|
8d7001adc3 | ||
|
|
f3e92b45fc | ||
|
|
64c2dc13ca | ||
|
|
a8a96235a8 | ||
|
|
29938f9cb0 | ||
|
|
d8ea7363f5 | ||
|
|
f8dd0dbfb4 | ||
|
|
bdec92caf8 | ||
|
|
4ae030fec1 | ||
|
|
c7d4d9690c | ||
|
|
39e64d8cc9 | ||
|
|
262ed72348 | ||
|
|
27c6a4eabc | ||
|
|
4df2933516 | ||
|
|
57d7d89b53 | ||
|
|
cab404578d | ||
|
|
ef6ae3071d | ||
|
|
b064ba08f3 | ||
|
|
f808926fbd | ||
|
|
f4ecc23213 | ||
|
|
0a633e361b | ||
|
|
2133d8f5b3 | ||
|
|
445da33efe | ||
|
|
a4b27a7248 | ||
|
|
52cb08b973 | ||
|
|
52a9794659 | ||
|
|
605c2bac86 | ||
|
|
01e1a0f44d | ||
|
|
52b4d7ba5a | ||
|
|
94d51ffe20 | ||
|
|
4fc5fb8690 | ||
|
|
b07a9e1843 | ||
|
|
8b46735b79 | ||
|
|
1353677a98 | ||
|
|
a576150ab5 | ||
|
|
7a033d7585 | ||
|
|
1f11ce8700 | ||
|
|
59bfb32221 | ||
|
|
04c042d9d1 | ||
|
|
8603545aef | ||
|
|
650755a092 | ||
|
|
71c588c16a | ||
|
|
0b99f92e97 | ||
|
|
05930b7bc9 | ||
|
|
12d0bccbd4 | ||
|
|
b5386249bd | ||
|
|
36a645ffd8 | ||
|
|
3bd2cd78c7 | ||
|
|
cbdda6b03b | ||
|
|
6355aaf33b | ||
|
|
e53bff712a | ||
|
|
b854992ae6 | ||
|
|
5042d71408 | ||
|
|
695ee2a041 | ||
|
|
cf8b7db4b4 | ||
|
|
5d8c6799fc | ||
|
|
bd368f5d3a | ||
|
|
87a04aba03 | ||
|
|
df4dddee0b | ||
|
|
eb63f9e7ae | ||
|
|
29b5999fd7 | ||
|
|
5707889555 | ||
|
|
ecdfd467f8 | ||
|
|
e5334a5a18 | ||
|
|
e5c4b27366 | ||
|
|
c18545a7f5 | ||
|
|
dc9e64308a | ||
|
|
b8e1c6a59d | ||
|
|
cf14b2a972 | ||
|
|
5a22a5c8a3 | ||
|
|
5e80ea3371 | ||
|
|
d0b3042940 | ||
|
|
de4f9e8908 | ||
|
|
ab94a13522 | ||
|
|
09c4142dad | ||
|
|
e0063880ac | ||
|
|
7ade772e0b | ||
|
|
a39c2a0068 | ||
|
|
17cab6d955 | ||
|
|
cad2498d87 | ||
|
|
6569ef09c5 | ||
|
|
78ea5d8c61 | ||
|
|
c3648f42b2 | ||
|
|
f90d5bc49e | ||
|
|
55e158fe81 | ||
|
|
5d48f277f2 | ||
|
|
2094a8e221 | ||
|
|
4b3c3132cb | ||
|
|
c83b3cda24 | ||
|
|
0a2c7a1070 | ||
|
|
178a44bd18 | ||
|
|
45d771dfb0 | ||
|
|
1726176b9b | ||
|
|
c6872cec5f | ||
|
|
14dd0c0d06 | ||
|
|
06af9c85da | ||
|
|
d509d5833d | ||
|
|
2c67350605 | ||
|
|
9ae4da3b38 | ||
|
|
8b79f9cbe7 | ||
|
|
3e4f8d1b9c | ||
|
|
f3b570cf8e | ||
|
|
d33b67cb33 | ||
|
|
ae9ede9aa6 | ||
|
|
584b19967a | ||
|
|
3c85154faf | ||
|
|
276423dcfb | ||
|
|
42f351a40d | ||
|
|
13f2282754 | ||
|
|
80cfb3c97c | ||
|
|
73082fd2ce | ||
|
|
bc29774553 | ||
|
|
ff68c01543 | ||
|
|
400fbf7839 | ||
|
|
f34406c57d | ||
|
|
adfa59f690 | ||
|
|
baf98ee6e9 | ||
|
|
dc2231cdfb | ||
|
|
4c41f14360 | ||
|
|
36ee304ed4 | ||
|
|
c3c5d6ff37 | ||
|
|
47d2651ea4 | ||
|
|
5c4ac32bb9 | ||
|
|
8b447e3a6f | ||
|
|
b065ca8cf4 | ||
|
|
2b906c31b5 | ||
|
|
b65d59f27e | ||
|
|
606e5dddf3 | ||
|
|
4f336c110b | ||
|
|
aae420aa8b | ||
|
|
b1a530c76a | ||
|
|
f6d626d979 | ||
|
|
2b2c6aa143 | ||
|
|
b66c2d1bea | ||
|
|
e65da8fab8 | ||
|
|
aef474b909 | ||
|
|
8a07a836e1 | ||
|
|
9f8be5ea6c | ||
|
|
83cb82d50f | ||
|
|
a986b1c226 | ||
|
|
d04b5d4f87 | ||
|
|
e646827d92 | ||
|
|
7ba45a0451 | ||
|
|
3af3eab3e4 | ||
|
|
d84b07a5cb | ||
|
|
c7ffa3a122 | ||
|
|
ecc89d7d93 | ||
|
|
30a321b1ce | ||
|
|
d7d0c2fc6d | ||
|
|
216e5b31dd | ||
|
|
47d69a842a | ||
|
|
74fc5d5573 | ||
|
|
7611c4dba6 | ||
|
|
25954e872e | ||
|
|
e2a9236106 | ||
|
|
882bc19fdd | ||
|
|
09bb643ef6 | ||
|
|
767c4422ac | ||
|
|
07bf5dbacc | ||
|
|
dfd1917d9b | ||
|
|
a046794e68 | ||
|
|
1e4e18240d | ||
|
|
8b45f32b33 | ||
|
|
25c75c5fc4 | ||
|
|
485f0b9caf | ||
|
|
fa643b269e | ||
|
|
60ee4a34aa | ||
|
|
f33c062d78 | ||
|
|
fce5af14a8 | ||
|
|
497e0d2d98 | ||
|
|
e0c878df5f | ||
|
|
5433d9fe5c | ||
|
|
dc35b3a93e | ||
|
|
4e43f90244 | ||
|
|
4d1fd05740 | ||
|
|
0089378a0a | ||
|
|
7e3b084819 | ||
|
|
53c365b752 | ||
|
|
9c359b682b | ||
|
|
7174c4c328 | ||
|
|
9ecd25a93b | ||
|
|
5ea0c141b5 | ||
|
|
12fc72147c | ||
|
|
cf7e10aacc | ||
|
|
09b4cbd32c | ||
|
|
8645e88e0e | ||
|
|
fa2464e843 | ||
|
|
51699e671a | ||
|
|
14c0f74707 | ||
|
|
77582a01b5 | ||
|
|
d7a153bdd4 | ||
|
|
7b352159df | ||
|
|
00f34d5e68 | ||
|
|
f8d90a8972 | ||
|
|
27d4f1fc97 | ||
|
|
f2206b8dbc | ||
|
|
713297ee04 | ||
|
|
37aee4d3a0 | ||
|
|
5ec6e62656 | ||
|
|
bf467e136a | ||
|
|
e95d1653ac | ||
|
|
5dc69c6cdb | ||
|
|
7659dd60ba | ||
|
|
6d71f5ffd7 | ||
|
|
2bf3d536ea | ||
|
|
a7e50dfe7f | ||
|
|
6d98d2c6ed | ||
|
|
a4b8935427 | ||
|
|
7fdbb427bc | ||
|
|
e44f76bbe4 | ||
|
|
f8d10289b5 | ||
|
|
8908465546 | ||
|
|
0ddb572c03 | ||
|
|
7ce139bd2c | ||
|
|
ecb29b7fa5 | ||
|
|
3b90a084b4 | ||
|
|
21d714ab6e | ||
|
|
9f7a59536c | ||
|
|
18dac30874 | ||
|
|
dcd4a0077c | ||
|
|
46e1c4f177 | ||
|
|
952f2b0829 | ||
|
|
0b1c3938c6 | ||
|
|
a895274add | ||
|
|
f24dd61329 | ||
|
|
ce18bb98ab | ||
|
|
a4d63010c9 | ||
|
|
68be2b8938 | ||
|
|
8353564d92 | ||
|
|
27525523be | ||
|
|
bbc08e4f5e | ||
|
|
f148af1bd6 | ||
|
|
654f570b6e | ||
|
|
a9043f2e80 | ||
|
|
02d7a758fe | ||
|
|
5034749463 | ||
|
|
9af494d36c | ||
|
|
e9f29ab3d6 | ||
|
|
5e753d211f | ||
|
|
3838536126 | ||
|
|
4aef0ada9d | ||
|
|
03176b505c | ||
|
|
27d3089804 | ||
|
|
987b932a19 | ||
|
|
ba947d842a | ||
|
|
dad9bf87ef | ||
|
|
71ef10bb60 | ||
|
|
06acc9546f | ||
|
|
cb02c23c32 | ||
|
|
c49ffa9723 | ||
|
|
55cb9d9c1f | ||
|
|
f1003df810 | ||
|
|
e4b9169221 | ||
|
|
81e892d19e | ||
|
|
a931d49f3e | ||
|
|
daa89115d5 | ||
|
|
0c6c44ba0b | ||
|
|
26e30b3859 | ||
|
|
d3a2237a5a | ||
|
|
1ca4961b27 | ||
|
|
95373bb042 | ||
|
|
ec8076536e | ||
|
|
100b457743 | ||
|
|
c7ea0c5958 | ||
|
|
35654cd709 | ||
|
|
b5eba89598 | ||
|
|
d9b764860a | ||
|
|
771e5c7c0c | ||
|
|
464efb1162 | ||
|
|
ee15eca351 | ||
|
|
cb83a7c3fd | ||
|
|
332d7f4ee1 | ||
|
|
bf168174d0 | ||
|
|
185a908811 | ||
|
|
7a372a642b | ||
|
|
2dcee2ccfc | ||
|
|
7702d96b33 | ||
|
|
b62dd2b6ee | ||
|
|
916360e2e5 | ||
|
|
b318adddac | ||
|
|
c1b06ccee8 | ||
|
|
c04895b222 | ||
|
|
2ea7459a89 | ||
|
|
edef01f579 | ||
|
|
b1cd9d1598 | ||
|
|
d6b2b4b144 | ||
|
|
cbf66a8077 | ||
|
|
fc82de7aa7 | ||
|
|
111b6de46c | ||
|
|
512e588e40 | ||
|
|
4921dc2213 | ||
|
|
d8db6fa9da | ||
|
|
493232ce5a | ||
|
|
17cb26b8b9 | ||
|
|
a0a7a35fe2 | ||
|
|
75ca552a4e | ||
|
|
3000bc8748 | ||
|
|
5f4bccd672 | ||
|
|
0428438e72 | ||
|
|
21cf732e7f | ||
|
|
a3b1dc01ea | ||
|
|
b524edc209 | ||
|
|
77466e7b6d | ||
|
|
e43d2054d1 | ||
|
|
9d52d72ae5 | ||
|
|
5ec45e5f7f | ||
|
|
6d7a680187 | ||
|
|
2f5838eaaa | ||
|
|
13ca38e4e0 | ||
|
|
4615fffafb | ||
|
|
1eab4322f8 | ||
|
|
c38d62b233 | ||
|
|
8fc6aced6c | ||
|
|
3474e7abc1 | ||
|
|
a513e01b01 | ||
|
|
113a96be0d | ||
|
|
705b6ec15c | ||
|
|
7945baf640 | ||
|
|
3c2e97d82e | ||
|
|
0cb874c9e1 | ||
|
|
fcf5dd036d | ||
|
|
477ab61e3b | ||
|
|
d24ea7572f | ||
|
|
f97f0bbda6 | ||
|
|
a2c621bf8b | ||
|
|
4014be78dc | ||
|
|
bee82b6ac3 | ||
|
|
28c7f04001 | ||
|
|
dc0a45d429 | ||
|
|
171d525aa4 | ||
|
|
758022006a | ||
|
|
8bfcbeaf48 | ||
|
|
8410b1383f | ||
|
|
ce891b57e1 | ||
|
|
5c0895e27f | ||
|
|
db9298fd3e | ||
|
|
d43c3091b2 | ||
|
|
32ebbd60f9 | ||
|
|
883b4af51d | ||
|
|
efc0a67e00 | ||
|
|
71727464b8 | ||
|
|
5c1d5c1f06 | ||
|
|
3d1bbaf54f | ||
|
|
80caf947f3 | ||
|
|
086848a7ad | ||
|
|
a74b66352e | ||
|
|
4f2b7f1829 | ||
|
|
eabf93f6cf | ||
|
|
4adc23a52a | ||
|
|
9667789621 | ||
|
|
9eb0954cde | ||
|
|
81e7748fb5 | ||
|
|
303280dd71 | ||
|
|
1e1133ec66 | ||
|
|
c32f366dfa | ||
|
|
ebde595370 | ||
|
|
7b0bb931b1 | ||
|
|
51e8bd9bd8 | ||
|
|
9276dba712 | ||
|
|
029cc67915 | ||
|
|
17d51ceed0 | ||
|
|
9e416a7921 | ||
|
|
031c8a7f52 | ||
|
|
2428b35f6c | ||
|
|
ff0e5c0348 | ||
|
|
839fdb211c | ||
|
|
2b9a06933b | ||
|
|
2f5e1b621e | ||
|
|
dfc0131516 | ||
|
|
b76badd958 | ||
|
|
1eb55cbba8 | ||
|
|
9484d6528c | ||
|
|
83ffc1f00d | ||
|
|
f4d5395c4b | ||
|
|
f6cf7f9ec7 | ||
|
|
c75ebbccec | ||
|
|
d6d316e304 | ||
|
|
833612ba9a | ||
|
|
6eff48e9ff | ||
|
|
f3cea7e7df | ||
|
|
7f0c88b5da | ||
|
|
8e39ae2703 | ||
|
|
66648c2343 | ||
|
|
e83d8d6a13 | ||
|
|
4c7ac2dddd | ||
|
|
088816d496 | ||
|
|
463ca625e1 | ||
|
|
2c9055a8bd | ||
|
|
3a2a22f30d | ||
|
|
fae1402a6e | ||
|
|
aa1399f790 | ||
|
|
17e6d41366 | ||
|
|
6872dadd74 | ||
|
|
4dd314dec3 | ||
|
|
07bc800f00 | ||
|
|
f3ed6619da | ||
|
|
62a9f00bd3 | ||
|
|
eabdf3a2ca | ||
|
|
1f85a7752b | ||
|
|
4767130954 | ||
|
|
582e0a0ab7 | ||
|
|
e63e6b110b | ||
|
|
a7bbd8a62b | ||
|
|
f158c34a21 | ||
|
|
659c037c84 | ||
|
|
4d1c5ebdd2 | ||
|
|
6516b569a9 | ||
|
|
cbc5710801 | ||
|
|
23be17f693 | ||
|
|
41b64e428c | ||
|
|
a74fa88812 | ||
|
|
dc1f934865 | ||
|
|
2b40cab3fe | ||
|
|
d4a2f72d10 | ||
|
|
0cbc0a757e | ||
|
|
6dad2c45ee | ||
|
|
28599ae1a5 | ||
|
|
0cee138670 | ||
|
|
1eba937874 | ||
|
|
5782fdca16 | ||
|
|
0a10fd4506 | ||
|
|
84117f2d1b | ||
|
|
db807e804a | ||
|
|
7a56371b84 | ||
|
|
b3f5d7dd59 | ||
|
|
4a44e16a09 | ||
|
|
6f6072b857 | ||
|
|
0fa40110e3 | ||
|
|
92f67ee847 | ||
|
|
cf4457bbb3 | ||
|
|
25c1947f1d | ||
|
|
955097ea77 | ||
|
|
cfdec92624 | ||
|
|
b4ab321a79 | ||
|
|
2ecf6f1070 | ||
|
|
f435c3af9e | ||
|
|
ee090039c7 | ||
|
|
17d2d13030 | ||
|
|
240b869db5 | ||
|
|
eaf581e544 | ||
|
|
ad71ec9fdf | ||
|
|
39dbdf8ddb | ||
|
|
a94e113410 | ||
|
|
0cfa65b48c | ||
|
|
6f819707b0 | ||
|
|
92ec2dcbdd | ||
|
|
645b62257c | ||
|
|
b4ea0496e7 | ||
|
|
1ffa5528b3 | ||
|
|
2be59f6edd | ||
|
|
103fe12b72 | ||
|
|
7efac13ac1 | ||
|
|
50f627b07e | ||
|
|
28c9e9db35 | ||
|
|
9efd3dc8ee | ||
|
|
529b91bc6e | ||
|
|
ed1840ddb5 | ||
|
|
cc2759d07e | ||
|
|
3545e20b01 | ||
|
|
6a1c641f75 | ||
|
|
17fc2b3e3b | ||
|
|
5d438ced79 | ||
|
|
43f9baa23a | ||
|
|
6d80ec69d7 | ||
|
|
9c7367bd4e | ||
|
|
de66fb9406 | ||
|
|
1d02cd2be0 | ||
|
|
b7ef08ca84 | ||
|
|
2432333f98 | ||
|
|
571911730a | ||
|
|
430895168d | ||
|
|
de46befc18 | ||
|
|
ba46b8c53e | ||
|
|
9353f9b28b | ||
|
|
992479d5a8 | ||
|
|
5a622c22b5 | ||
|
|
3c0a4410ad | ||
|
|
ecbeca36e7 | ||
|
|
0aad12fe1b | ||
|
|
00dca9601e | ||
|
|
f2f52c1e2c | ||
|
|
f3ddec372f | ||
|
|
e411b513be | ||
|
|
5ddd26e483 | ||
|
|
21ac0be8d7 | ||
|
|
f3c513bafd | ||
|
|
ff8f4a7217 | ||
|
|
d9efaee9b9 | ||
|
|
ebee84755e | ||
|
|
4f0b7b4511 | ||
|
|
fde96be168 | ||
|
|
820ef6c323 | ||
|
|
2de07250dc | ||
|
|
3ab91a45c9 | ||
|
|
c03a6f4386 | ||
|
|
328de502ac | ||
|
|
511e10d594 | ||
|
|
3c8507c4a3 | ||
|
|
ae4f68f695 | ||
|
|
b189c7b472 | ||
|
|
f84762d84a | ||
|
|
cf1074cf49 | ||
|
|
9756e15a23 | ||
|
|
a4d71d8fe2 | ||
|
|
34c63a665d | ||
|
|
fc7f9ff505 | ||
|
|
e1b6f5ad31 | ||
|
|
6d25033822 | ||
|
|
a4603c6f1a | ||
|
|
9c82785077 | ||
|
|
1c04d96468 | ||
|
|
5318dfe252 | ||
|
|
76642ccafa | ||
|
|
c565d9b1e6 | ||
|
|
09a9d9b54c | ||
|
|
701f51b1cc | ||
|
|
4188cc2f75 | ||
|
|
09fa22898d | ||
|
|
1cddbeb12f | ||
|
|
09c6586480 | ||
|
|
25701cfa6f | ||
|
|
4960970dbd | ||
|
|
19ac738b77 | ||
|
|
7876a2f321 | ||
|
|
f7a4c777e8 | ||
|
|
b375397efb | ||
|
|
6574e1d914 | ||
|
|
91ecc85e93 | ||
|
|
96404f1fd9 | ||
|
|
288366c96d | ||
|
|
64a1612b70 | ||
|
|
69a8839ce9 | ||
|
|
47f15dd307 | ||
|
|
505bf24abb | ||
|
|
a17c59ce1d | ||
|
|
74db00fc89 | ||
|
|
1587d6da03 | ||
|
|
c4baba880e | ||
|
|
020ac1b509 | ||
|
|
8424f166cc | ||
|
|
a6a8c0e845 | ||
|
|
1d39ff720e | ||
|
|
f93c9c0c5c | ||
|
|
b5dfcd05cb | ||
|
|
8733cb89c7 | ||
|
|
8f5fdc1f9a | ||
|
|
ec7067c55e | ||
|
|
bf3b7b2c62 | ||
|
|
b3ad79e2c5 | ||
|
|
7fe6a18f03 | ||
|
|
d6dc4b667b | ||
|
|
59c11404e6 | ||
|
|
5ef0fb8ac8 | ||
|
|
119415b8e9 | ||
|
|
d06fdcff85 | ||
|
|
9d4f862210 | ||
|
|
5055d1f1d5 | ||
|
|
b798147c33 | ||
|
|
2a64387259 | ||
|
|
71179da2f6 | ||
|
|
a584bd187b | ||
|
|
7d1d3c0206 | ||
|
|
d2c884da86 | ||
|
|
0b7840ab2f | ||
|
|
977cc71fd9 | ||
|
|
023d218104 | ||
|
|
4e6c558bf2 | ||
|
|
6a525748c4 | ||
|
|
c3aa36323b | ||
|
|
a1ba0c9166 | ||
|
|
e618f44667 | ||
|
|
9e296bde3c | ||
|
|
015e3621a3 | ||
|
|
cae194f493 | ||
|
|
4fbd247231 | ||
|
|
e94a261bf5 | ||
|
|
9022d40e6a | ||
|
|
38d8acfa18 | ||
|
|
7ca9e9c54b | ||
|
|
64c561f0bd | ||
|
|
f2c0c3f8fb | ||
|
|
5f9bd3ecbd | ||
|
|
8796d3cd95 | ||
|
|
cc56720bd2 | ||
|
|
88faf1023a | ||
|
|
42f517ec69 | ||
|
|
4791109a28 | ||
|
|
19391d8ab0 | ||
|
|
59a779c38a | ||
|
|
b579b37db4 | ||
|
|
4aad5f23a0 | ||
|
|
e6047bd54b | ||
|
|
24c2f2fa38 | ||
|
|
6b1e5335bc | ||
|
|
2e94bfafea | ||
|
|
b09cd1a197 | ||
|
|
d63e5bbd8a | ||
|
|
6337aa6fad | ||
|
|
08ebbb395a | ||
|
|
87c8a72831 | ||
|
|
11f37bc6eb | ||
|
|
a5d88d697a | ||
|
|
f89c0d74dd | ||
|
|
9e60357fc8 | ||
|
|
75e0f9f60e | ||
|
|
9717d3e1da | ||
|
|
b822ea43b9 | ||
|
|
ac99621829 | ||
|
|
99d66db930 | ||
|
|
c27fceb7de | ||
|
|
845322b5fb | ||
|
|
ef7e98c616 | ||
|
|
a3919cb0ec | ||
|
|
034bd641de | ||
|
|
ca1c00f95d | ||
|
|
0add3eaacb | ||
|
|
574d4dcedc | ||
|
|
82d6bcbbea | ||
|
|
e87fedd27c | ||
|
|
fab2af8876 | ||
|
|
e8573173dd | ||
|
|
13e3c8b42a | ||
|
|
280c9127c1 | ||
|
|
6573df6cc3 | ||
|
|
03c9156c80 | ||
|
|
02cdf05848 | ||
|
|
e9bf3cdb98 | ||
|
|
6cb9f0c695 | ||
|
|
6152d68b6a | ||
|
|
88b88251e7 | ||
|
|
48fc0bd220 | ||
|
|
619f18fea0 | ||
|
|
7b518511df | ||
|
|
5c1118230d | ||
|
|
0dfefe391c | ||
|
|
b3a8da9b25 | ||
|
|
84f3ff2afd | ||
|
|
f5587b74f0 | ||
|
|
1174994211 | ||
|
|
049caf9131 | ||
|
|
39aed35644 | ||
|
|
a9aef28966 | ||
|
|
790d248111 | ||
|
|
640cd0f411 | ||
|
|
cfe8e320be | ||
|
|
5780bf40d4 | ||
|
|
31d3e88d32 | ||
|
|
7ecaa8afdd | ||
|
|
8c996d2efd | ||
|
|
d8b4281c06 | ||
|
|
c82eb3e80f | ||
|
|
14571658a2 | ||
|
|
aa4473e2c6 | ||
|
|
9deef4189c | ||
|
|
25d81e0f1d | ||
|
|
70590a759d | ||
|
|
8d01442d75 | ||
|
|
d65483ae16 | ||
|
|
7c6e53ddfb | ||
|
|
ff0c36b465 | ||
|
|
dafce45e49 | ||
|
|
be6af15754 | ||
|
|
cbc0625272 | ||
|
|
fd1f465fa7 | ||
|
|
8ed39e4ae5 | ||
|
|
3adb801ca8 | ||
|
|
ccf7b28723 | ||
|
|
e876217e24 | ||
|
|
ec0c57d0e1 | ||
|
|
87a7c4f94b | ||
|
|
27257d0288 | ||
|
|
245bc9bfab | ||
|
|
fa519f5108 | ||
|
|
30d83cb94a | ||
|
|
f5c79bf50c | ||
|
|
ea1324a9f1 | ||
|
|
261a8899fc | ||
|
|
a5de549456 | ||
|
|
bdaa857c49 | ||
|
|
1c14900093 | ||
|
|
01f385a6f7 | ||
|
|
cf6b57d659 | ||
|
|
f742ab4994 | ||
|
|
cfac1c347c | ||
|
|
047e8f9349 | ||
|
|
3d87a68561 | ||
|
|
66433c1869 | ||
|
|
869ae21c9f | ||
|
|
03fd5b15da | ||
|
|
fecd582035 | ||
|
|
180e9bd362 | ||
|
|
2fbb6ba1e9 | ||
|
|
51e12b3866 | ||
|
|
a6f9d78c1c | ||
|
|
8cf82c24dc | ||
|
|
438382c5df | ||
|
|
1ab44722e8 | ||
|
|
4291776473 | ||
|
|
06a5ef3cd8 | ||
|
|
9d9ee8b45f | ||
|
|
a22b670a00 | ||
|
|
8c6cc302d0 | ||
|
|
afcee77abe | ||
|
|
294eb75355 | ||
|
|
e472228f29 | ||
|
|
fb925e7aa5 | ||
|
|
a141082b91 | ||
|
|
71768ea6c3 | ||
|
|
ed39922f85 | ||
|
|
1da3f71357 | ||
|
|
c3d4f24720 | ||
|
|
9df4a54308 | ||
|
|
492c6c6843 | ||
|
|
a12c2ab3e1 | ||
|
|
f2f6ae4f29 | ||
|
|
679850a267 | ||
|
|
c90b65a72c | ||
|
|
d02d252690 | ||
|
|
b785d34d29 | ||
|
|
f5eef5390a | ||
|
|
97d559982e | ||
|
|
7a701546e1 | ||
|
|
ea63799c3e | ||
|
|
c05c3e4065 | ||
|
|
c629c5bb59 | ||
|
|
53b98a5022 | ||
|
|
f0347f0589 | ||
|
|
06a5a5bb36 | ||
|
|
08f6cbb675 | ||
|
|
1a406d079b | ||
|
|
3afa29d499 | ||
|
|
b98f142e0e | ||
|
|
894ac21532 | ||
|
|
e1132672ee | ||
|
|
15226b9332 | ||
|
|
1b85022c58 | ||
|
|
dbc479e490 | ||
|
|
5792cea985 | ||
|
|
16e8710a81 | ||
|
|
503ec7c2e6 | ||
|
|
11ee7e984c | ||
|
|
8d0ae1f894 | ||
|
|
95daea76fc | ||
|
|
8ca0b4580e | ||
|
|
80fc651d7e | ||
|
|
0f944cdc55 | ||
|
|
7653e9e04c | ||
|
|
7c866328e0 | ||
|
|
0d4879763a | ||
|
|
440dbfb6df | ||
|
|
875b202cbb | ||
|
|
beb005138a | ||
|
|
a94dc6a058 | ||
|
|
1c88c74f86 | ||
|
|
dfcfb51bef | ||
|
|
49786ccc34 | ||
|
|
c4284b2938 | ||
|
|
a90c9f9c3e | ||
|
|
bb006b46e6 | ||
|
|
f9706f260a | ||
|
|
319de22d89 | ||
|
|
115f760821 | ||
|
|
b9fc93955c | ||
|
|
f2756b5318 | ||
|
|
3a8778e2f8 | ||
|
|
58e17b3cdc | ||
|
|
cc6f285abd | ||
|
|
04c9bcd802 | ||
|
|
c8d0813669 | ||
|
|
9b9a9f359e | ||
|
|
b51a4de540 | ||
|
|
65f97a60ad | ||
|
|
4f07cba011 | ||
|
|
aad4bf2464 | ||
|
|
329facfbdf | ||
|
|
a4b6ef577e | ||
|
|
01e75761d3 | ||
|
|
737ff18498 | ||
|
|
d28efe8797 | ||
|
|
b560f04046 | ||
|
|
066762217f | ||
|
|
1a661a2d15 | ||
|
|
aefe9a4195 | ||
|
|
1d515adc22 | ||
|
|
9cdda243a1 | ||
|
|
22746985f2 | ||
|
|
76368bda60 | ||
|
|
88ecf49549 | ||
|
|
e7b66aa43a | ||
|
|
152141d7f4 | ||
|
|
466f5e23db | ||
|
|
eea1f6be63 | ||
|
|
5da1649653 | ||
|
|
c0af145165 | ||
|
|
a8283d1cc3 | ||
|
|
cc0530cbf6 | ||
|
|
a8263b1b4f | ||
|
|
bc5cbcf39b | ||
|
|
729b3f0a8f | ||
|
|
52c24ed061 | ||
|
|
ba1b4a41a9 | ||
|
|
f8e0797773 | ||
|
|
c8b457da38 | ||
|
|
e3723dcda5 | ||
|
|
46d3a81ba0 | ||
|
|
b6b033a52b | ||
|
|
98527317a8 | ||
|
|
8f0a202e0c | ||
|
|
5574d1c32f | ||
|
|
cfb4309479 | ||
|
|
91f48c5588 | ||
|
|
67b61c4af9 | ||
|
|
ccb06ce3cb | ||
|
|
2d8d064ce8 | ||
|
|
4c70c67042 | ||
|
|
d82624411e | ||
|
|
1d3b911b16 | ||
|
|
c038bf8198 | ||
|
|
30cc80efe3 | ||
|
|
ea9bd50fca | ||
|
|
15fc7e58a8 | ||
|
|
e57acace0b | ||
|
|
a697464a33 | ||
|
|
42b259d124 | ||
|
|
1fd1b320c2 | ||
|
|
1669c0afbd | ||
|
|
cf87c88b05 | ||
|
|
fafe7a7cfc | ||
|
|
99c27f57b1 | ||
|
|
367c6eb704 | ||
|
|
1086495096 | ||
|
|
17ec55a3b3 | ||
|
|
3f1ebebde5 | ||
|
|
ac2cc54e13 | ||
|
|
cc0db5f166 | ||
|
|
5892ffc382 | ||
|
|
45329d05a5 | ||
|
|
02a6b3bb38 | ||
|
|
732a307c75 | ||
|
|
b03a419c6b | ||
|
|
ba08c21517 | ||
|
|
81064faac3 | ||
|
|
f0c82200ba | ||
|
|
c3c3af34fd | ||
|
|
dd04583dcb | ||
|
|
0b7c0be29a | ||
|
|
d277dcd5d7 | ||
|
|
939e9f40b5 | ||
|
|
6546556a14 | ||
|
|
6193d8c554 | ||
|
|
ab6fd322d1 | ||
|
|
7e742f6e1f | ||
|
|
fa5268fa2d | ||
|
|
fd80e5c653 | ||
|
|
2814054863 | ||
|
|
241941a44a | ||
|
|
35295d2e27 | ||
|
|
6011d45e38 | ||
|
|
9ddb013875 | ||
|
|
e5c7fd1c55 | ||
|
|
99eebd00c4 | ||
|
|
bddf2a311b | ||
|
|
9a30f05f80 | ||
|
|
2ea173a254 | ||
|
|
ba0e1b5719 | ||
|
|
f9b042c375 | ||
|
|
c7701b8a61 | ||
|
|
03c1c21fd3 | ||
|
|
473c29a70d | ||
|
|
ad4ce5f441 | ||
|
|
ef06407da6 | ||
|
|
bbabccf9aa | ||
|
|
3827f817c7 | ||
|
|
8b400331c7 | ||
|
|
cef882616b | ||
|
|
4592cba19f | ||
|
|
b1018ad64b | ||
|
|
5ce52bd775 | ||
|
|
0193a3fe54 | ||
|
|
fb0133cd4b | ||
|
|
370cc028cb | ||
|
|
9fd6c8a1ee | ||
|
|
4e089766a5 | ||
|
|
cc80175e89 | ||
|
|
8a4f4bff9b | ||
|
|
2ace33f8b7 | ||
|
|
edd9efd1b3 | ||
|
|
8f240861e3 | ||
|
|
019611c764 | ||
|
|
491253fa03 | ||
|
|
07863c0d46 | ||
|
|
879911b721 | ||
|
|
1beec23065 | ||
|
|
5623338662 | ||
|
|
941d53ebfd | ||
|
|
9ce29e8ec5 | ||
|
|
aa42db6e25 | ||
|
|
04e2728dc2 | ||
|
|
b949d86c40 | ||
|
|
85c34c4dcf | ||
|
|
b65f336f81 | ||
|
|
9b43d265c3 | ||
|
|
ea27dff338 | ||
|
|
a23e845244 | ||
|
|
6b2c1fe969 | ||
|
|
af349ade33 | ||
|
|
b3468451f5 | ||
|
|
48f7c67587 | ||
|
|
e5568118ac | ||
|
|
a48e072076 | ||
|
|
531df6eaba | ||
|
|
64ad8c32f2 | ||
|
|
d8845b88f4 | ||
|
|
e7d8dd5ef7 | ||
|
|
1b9bc33bcf | ||
|
|
a4f0b4c5fb | ||
|
|
872f25dcc6 | ||
|
|
2a40650926 | ||
|
|
a76f40eb83 |
35
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
35
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen and what happened instead.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Versions (please complete the following information):**
|
||||||
|
- OS: [e.g. Windows 10, MacOS 13.2, Ubuntu 22.10]
|
||||||
|
- CEF Version: [e.g. 111.2.2]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Does the problem reproduce with the cefclient or cefsimple sample application at the same version?
|
||||||
|
|
||||||
|
Does the problem reproduce with Google Chrome at the same version?
|
||||||
|
|
||||||
|
Add any other context about the problem here.
|
||||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -35,6 +35,7 @@
|
|||||||
.metadata
|
.metadata
|
||||||
.project
|
.project
|
||||||
.pydevproject
|
.pydevproject
|
||||||
|
.vscode
|
||||||
# Settings directory for eclipse
|
# Settings directory for eclipse
|
||||||
/.settings
|
/.settings
|
||||||
.checkstyle
|
.checkstyle
|
||||||
@@ -42,6 +43,10 @@ cscope.*
|
|||||||
Session.vim
|
Session.vim
|
||||||
tags
|
tags
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
# IDE's
|
||||||
|
.vs/
|
||||||
|
.kdev4/
|
||||||
|
*.kdev4
|
||||||
# CEF generated directories
|
# CEF generated directories
|
||||||
/binary_distrib
|
/binary_distrib
|
||||||
/docs
|
/docs
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# This file is an addendum to the Chromium AUTHORS file.
|
# This file is an addendum to the Chromium AUTHORS file. It lists authors
|
||||||
# Names should be added to this file like so:
|
# through March 16, 2015 when Git was introduced for source code management.
|
||||||
# Name or Organization <email address>
|
# A list of additional authors added after that date can be found by executing
|
||||||
|
# this command on a local Git checkout:
|
||||||
|
# git log --all --format="%aN <%aE>" | sort -u
|
||||||
|
|
||||||
Marshall Greenblatt <magreenblatt@gmail.com>
|
Marshall Greenblatt <magreenblatt@gmail.com>
|
||||||
Jamie Kirkpatrick <jkp@spotify.com>
|
Jamie Kirkpatrick <jkp@spotify.com>
|
||||||
|
|||||||
@@ -7,5 +7,6 @@
|
|||||||
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
# https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
||||||
|
|
||||||
{
|
{
|
||||||
'chromium_checkout': 'refs/tags/74.0.3729.0'
|
'chromium_checkout': 'refs/tags/132.0.6834.161',
|
||||||
|
'depot_tools_checkout': 'c9552ffad5'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,25 +27,11 @@
|
|||||||
# Files in the chromium/src directory that should be evaluated for changes.
|
# Files in the chromium/src directory that should be evaluated for changes.
|
||||||
# Similar changes may need to be applied to the CEF source code.
|
# Similar changes may need to be applied to the CEF source code.
|
||||||
'files': [
|
'files': [
|
||||||
'chrome/app/chrome_*_manifest.*',
|
'components/content_settings/core/common/content_settings_types.mojom',
|
||||||
'chrome/app/chrome_*_manifests.*',
|
'components/permissions/request_type.h',
|
||||||
'chrome/browser/browser_process.h',
|
|
||||||
'chrome/browser/extensions/api/tabs/tabs_api.*',
|
|
||||||
'chrome/browser/extensions/chrome_component_extension_resource_manager.*',
|
|
||||||
'chrome/browser/extensions/chrome_extension_web_contents_observer.*',
|
|
||||||
'chrome/browser/extensions/component_loader.*',
|
|
||||||
'chrome/browser/extensions/extension_service.*',
|
|
||||||
'chrome/browser/printing/print_view_manager*',
|
|
||||||
'chrome/browser/printing/printing_message_filter*',
|
|
||||||
'chrome/browser/profiles/profile.h',
|
|
||||||
'chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.*',
|
|
||||||
'chrome/common/extensions/api/*_features.json',
|
|
||||||
'chrome/renderer/chrome_content_renderer_client.*',
|
|
||||||
'chrome/renderer/extensions/chrome_extensions_renderer_client.*',
|
|
||||||
'content/browser/renderer_host/render_widget_host_view_base.*',
|
'content/browser/renderer_host/render_widget_host_view_base.*',
|
||||||
'content/public/browser/content_browser_client.*',
|
'content/public/browser/content_browser_client.*',
|
||||||
'content/public/browser/render_widget_host_view.h',
|
'content/public/browser/render_widget_host_view.h',
|
||||||
'content/public/browser/storage_partition.h',
|
|
||||||
'content/public/browser/web_contents_delegate.h',
|
'content/public/browser/web_contents_delegate.h',
|
||||||
'content/public/common/content_features.cc',
|
'content/public/common/content_features.cc',
|
||||||
'content/shell/BUILD.gn',
|
'content/shell/BUILD.gn',
|
||||||
@@ -57,19 +43,12 @@
|
|||||||
'content/shell/renderer/shell_*',
|
'content/shell/renderer/shell_*',
|
||||||
'content/shell/utility/shell_*',
|
'content/shell/utility/shell_*',
|
||||||
'extensions/shell/*',
|
'extensions/shell/*',
|
||||||
|
'net/base/features.cc',
|
||||||
'net/cookies/cookie_store.h',
|
'net/cookies/cookie_store.h',
|
||||||
|
'services/network/public/cpp/features.cc',
|
||||||
|
'ui/base/ui_base_features.cc',
|
||||||
],
|
],
|
||||||
# Patterns that should not be found in the chromium/src directory after
|
# Patterns that should not be found in the chromium/src directory after
|
||||||
# applying patch files.
|
# applying patch files.
|
||||||
'patterns': [
|
'patterns': [],
|
||||||
{
|
|
||||||
# New instances of this static_cast are added to the Chromium sources with
|
|
||||||
# some regularity. If unfixed they will result in runtime crashes.
|
|
||||||
'pattern': 'static_cast<StoragePartitionImpl\*>(',
|
|
||||||
'exclude_matches': '^(.+?)test(.+?):',
|
|
||||||
'message': 'New instances in non-test files should be converted to ' +\
|
|
||||||
'call StoragePartition methods.' +\
|
|
||||||
'\nSee storage_partition_1973.patch.',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
# CMake-generated project formats that have been tested with this CEF binary
|
# CMake-generated project formats that have been tested with this CEF binary
|
||||||
# distribution include:
|
# distribution include:
|
||||||
#
|
#
|
||||||
# Linux: Ninja, Unix Makefiles
|
# Linux: Ninja, GCC 7.5.0+, Unix Makefiles
|
||||||
# Mac OS X: Ninja, Xcode 5+
|
# MacOS: Ninja, Xcode 12.2 to 15.0
|
||||||
# Windows: Ninja, Visual Studio 2010+
|
# Windows: Ninja, Visual Studio 2022
|
||||||
#
|
#
|
||||||
# Ninja is a cross-platform open-source tool for running fast builds using
|
# Ninja is a cross-platform open-source tool for running fast builds using
|
||||||
# pre-installed platform toolchains (GNU, clang, Xcode or MSVC). It can be
|
# pre-installed platform toolchains (GNU, clang, Xcode or MSVC). It can be
|
||||||
@@ -36,25 +36,26 @@
|
|||||||
#
|
#
|
||||||
# The below requirements must be met to build this CEF binary distribution.
|
# The below requirements must be met to build this CEF binary distribution.
|
||||||
#
|
#
|
||||||
# - CMake version 2.8.12.1 or newer.
|
# - CMake version 3.21 or newer.
|
||||||
#
|
#
|
||||||
# - Linux requirements:
|
# - Linux requirements:
|
||||||
# Currently supported distributions include Debian Wheezy, Ubuntu Precise, and
|
# Currently supported distributions include Debian 10 (Buster), Ubuntu 18
|
||||||
# related. Ubuntu 14.04 64-bit is recommended. Newer versions will likely also
|
# (Bionic Beaver), and related. Ubuntu 18.04 64-bit with GCC 7.5.0+ is
|
||||||
# work but may not have been tested.
|
# recommended. Newer versions will likely also work but may not have been
|
||||||
|
# tested.
|
||||||
# Required packages include:
|
# Required packages include:
|
||||||
# build-essential
|
# build-essential
|
||||||
# libgtk2.0-dev (required by the cefclient target only)
|
# libgtk3.0-dev (required by the cefclient target only)
|
||||||
# libgtkglext1-dev (required by the cefclient target only)
|
|
||||||
#
|
#
|
||||||
# - Mac OS X requirements:
|
# - MacOS requirements:
|
||||||
# Xcode 5 or newer building on Mac OS X 10.9 (Mavericks) or newer. Xcode 8.3
|
# Xcode 12.2 to 15.4 building on MacOS 11.0 (Big Sur) or newer. The Xcode
|
||||||
# and OS X 10.12 are recommended. The Xcode command-line tools must also be
|
# command-line tools must also be installed. Newer Xcode versions may not have
|
||||||
# installed. Only 64-bit builds are supported on OS X.
|
# been been tested and are not recommended.
|
||||||
#
|
#
|
||||||
# - Windows requirements:
|
# - Windows requirements:
|
||||||
# Visual Studio 2010 or newer building on Windows 7 or newer. Visual Studio
|
# Visual Studio 2022 building on Windows 10 or newer. Windows 10/11 64-bit is
|
||||||
# 2015 Update 3 and Windows 10 64-bit are recommended.
|
# recommended. Newer versions will likely also work but may not have been
|
||||||
|
# tested.
|
||||||
#
|
#
|
||||||
# BUILD EXAMPLES
|
# BUILD EXAMPLES
|
||||||
#
|
#
|
||||||
@@ -75,7 +76,7 @@
|
|||||||
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
# > ninja cefclient cefsimple
|
# > ninja cefclient cefsimple
|
||||||
#
|
#
|
||||||
# To perform a Mac OS X build using a 64-bit CEF binary distribution:
|
# To perform a MacOS build using a 64-bit CEF binary distribution:
|
||||||
# Using the Xcode IDE:
|
# Using the Xcode IDE:
|
||||||
# > cmake -G "Xcode" -DPROJECT_ARCH="x86_64" ..
|
# > cmake -G "Xcode" -DPROJECT_ARCH="x86_64" ..
|
||||||
# Open build\cef.xcodeproj in Xcode and select Product > Build.
|
# Open build\cef.xcodeproj in Xcode and select Product > Build.
|
||||||
@@ -84,33 +85,54 @@
|
|||||||
# > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
|
# > cmake -G "Ninja" -DPROJECT_ARCH="x86_64" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
# > ninja cefclient cefsimple
|
# > ninja cefclient cefsimple
|
||||||
#
|
#
|
||||||
|
# To perform a MacOS build using an ARM64 CEF binary distribution:
|
||||||
|
# Using the Xcode IDE:
|
||||||
|
# > cmake -G "Xcode" -DPROJECT_ARCH="arm64" ..
|
||||||
|
# Open build\cef.xcodeproj in Xcode and select Product > Build.
|
||||||
|
#
|
||||||
|
# Using Ninja:
|
||||||
|
# > cmake -G "Ninja" -DPROJECT_ARCH="arm64" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
|
# > ninja cefclient cefsimple
|
||||||
|
#
|
||||||
# To perform a Windows build using a 32-bit CEF binary distribution:
|
# To perform a Windows build using a 32-bit CEF binary distribution:
|
||||||
# Using the Visual Studio 2015 IDE:
|
# Using the Visual Studio 2022 IDE:
|
||||||
# > cmake -G "Visual Studio 14" ..
|
# > cmake -G "Visual Studio 17" -A Win32 ..
|
||||||
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
||||||
#
|
#
|
||||||
# Using Ninja with Visual Studio 2015 command-line tools:
|
# Using Ninja with Visual Studio 2022 command-line tools:
|
||||||
# (this path may be different depending on your Visual Studio installation)
|
# (this path may be different depending on your Visual Studio installation)
|
||||||
# > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
|
# > "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars32.bat"
|
||||||
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
# > ninja cefclient cefsimple
|
# > ninja cefclient cefsimple
|
||||||
#
|
#
|
||||||
# To perform a Windows build using a 64-bit CEF binary distribution:
|
# To perform a Windows build using a 64-bit CEF binary distribution:
|
||||||
# Using the Visual Studio 2015 IDE:
|
# Using the Visual Studio 2022 IDE:
|
||||||
# > cmake -G "Visual Studio 14 Win64" ..
|
# > cmake -G "Visual Studio 17" -A x64 ..
|
||||||
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
||||||
#
|
#
|
||||||
# Using Ninja with Visual Studio 2015 command-line tools:
|
# Using Ninja with Visual Studio 2022 command-line tools:
|
||||||
# (this path may be different depending on your Visual Studio installation)
|
# (this path may be different depending on your Visual Studio installation)
|
||||||
# > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
|
# > "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars64.bat"
|
||||||
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
# > ninja cefclient cefsimple
|
# > ninja cefclient cefsimple
|
||||||
|
#
|
||||||
|
# To perform a Windows build using an ARM64 CEF binary distribution:
|
||||||
|
# Using the Visual Studio 2022 IDE:
|
||||||
|
# > cmake -G "Visual Studio 17" -A arm64 ..
|
||||||
|
# Open build\cef.sln in Visual Studio and select Build > Build Solution.
|
||||||
|
#
|
||||||
|
# Using Ninja with Visual Studio 2022 command-line tools:
|
||||||
|
# (this path may be different depending on your Visual Studio installation)
|
||||||
|
# > "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsamd64_arm64.bat"
|
||||||
|
# > cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
|
# > ninja cefsimple
|
||||||
|
|
||||||
#
|
#
|
||||||
# Global setup.
|
# Global setup.
|
||||||
#
|
#
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8.12.1)
|
# For VS2022 and Xcode 12+ support.
|
||||||
|
cmake_minimum_required(VERSION 3.21)
|
||||||
|
|
||||||
# Only generate Debug and Release configuration types.
|
# Only generate Debug and Release configuration types.
|
||||||
set(CMAKE_CONFIGURATION_TYPES Debug Release)
|
set(CMAKE_CONFIGURATION_TYPES Debug Release)
|
||||||
@@ -120,7 +142,7 @@ set(CMAKE_CONFIGURATION_TYPES Debug Release)
|
|||||||
project(cef)
|
project(cef)
|
||||||
|
|
||||||
# Use folders in the resulting project files.
|
# Use folders in the resulting project files.
|
||||||
set_property(GLOBAL PROPERTY OS_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -200,11 +222,35 @@ add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
|
|||||||
# Comes from the <target>/CMakeLists.txt file in the current directory.
|
# Comes from the <target>/CMakeLists.txt file in the current directory.
|
||||||
# TODO: Change these lines to match your project target when you copy this file.
|
# TODO: Change these lines to match your project target when you copy this file.
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
||||||
add_subdirectory(tests/cefclient)
|
|
||||||
add_subdirectory(tests/cefsimple)
|
add_subdirectory(tests/cefsimple)
|
||||||
add_subdirectory(tests/gtest)
|
add_subdirectory(tests/gtest)
|
||||||
add_subdirectory(tests/ceftests)
|
add_subdirectory(tests/ceftests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/cefclient")
|
||||||
|
add_subdirectory(tests/cefclient)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Display configuration settings.
|
# Display configuration settings.
|
||||||
PRINT_CEF_CONFIG()
|
PRINT_CEF_CONFIG()
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Define the API documentation target.
|
||||||
|
#
|
||||||
|
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile")
|
||||||
|
find_package(Doxygen)
|
||||||
|
if(DOXYGEN_FOUND)
|
||||||
|
add_custom_target(apidocs ALL
|
||||||
|
# Generate documentation in the docs/html directory.
|
||||||
|
COMMAND "${DOXYGEN_EXECUTABLE}" Doxyfile
|
||||||
|
# Write a docs/index.html file.
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "<html><head><meta http-equiv=\"refresh\" content=\"0;URL='html/index.html'\"/></head></html>" > docs/index.html
|
||||||
|
WORKING_DIRECTORY "${CEF_ROOT}"
|
||||||
|
COMMENT "Generating API documentation with Doxygen..."
|
||||||
|
VERBATIM )
|
||||||
|
else()
|
||||||
|
message(WARNING "Doxygen must be installed to generate API documentation.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2008-2014 Marshall A. Greenblatt. Portions Copyright (c)
|
// Copyright (c) 2008-2020 Marshall A. Greenblatt. Portions Copyright (c)
|
||||||
// 2006-2009 Google Inc. All rights reserved.
|
// 2006-2009 Google Inc. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
27
README.md
27
README.md
@@ -9,9 +9,9 @@ The Chromium Embedded Framework (CEF) is a simple framework for embedding Chromi
|
|||||||
* Branches and Building - https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
* Branches and Building - https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
|
||||||
* Announcements - https://groups.google.com/forum/#!forum/cef-announce
|
* Announcements - https://groups.google.com/forum/#!forum/cef-announce
|
||||||
* Support Forum - http://www.magpcss.org/ceforum/
|
* Support Forum - http://www.magpcss.org/ceforum/
|
||||||
* CEF1 C++ API Docs - http://magpcss.org/ceforum/apidocs/
|
* Issue Tracker - https://github.com/chromiumembedded/cef/issues
|
||||||
* CEF3 C++ API Docs - http://magpcss.org/ceforum/apidocs3/
|
* C++ API Docs - [Stable release docs](https://cef-builds.spotifycdn.com/docs/stable.html) / [Beta release docs](https://cef-builds.spotifycdn.com/docs/beta.html)
|
||||||
* Downloads - http://opensource.spotify.com/cefbuilds/index.html
|
* Downloads - https://cef-builds.spotifycdn.com/index.html
|
||||||
* Donations - http://www.magpcss.org/ceforum/donate.php
|
* Donations - http://www.magpcss.org/ceforum/donate.php
|
||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
@@ -29,11 +29,11 @@ Numerous individuals and organizations contribute time and resources to support
|
|||||||
|
|
||||||
# Getting Started
|
# Getting Started
|
||||||
|
|
||||||
Users new to CEF development should start by reading the [Tutorial](https://bitbucket.org/chromiumembedded/cef/wiki/Tutorial) Wiki page for an overview of CEF usage and then proceed to the [GeneralUsage](https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage) Wiki page for a more in-depth discussion or architectural and usage issues. Complete API documentation is available [here](http://magpcss.org/ceforum/apidocs3/). CEF support and related discussion is available on the [CEF Forum](http://www.magpcss.org/ceforum/).
|
Users new to CEF development should start by reading the [Tutorial](https://bitbucket.org/chromiumembedded/cef/wiki/Tutorial) Wiki page for an overview of CEF usage and then proceed to the [GeneralUsage](https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage) Wiki page for a more in-depth discussion or architectural and usage issues. Complete API documentation is available [here](https://cef-builds.spotifycdn.com/docs/stable.html). CEF support and related discussion is available on the [CEF Forum](http://www.magpcss.org/ceforum/).
|
||||||
|
|
||||||
# Binary Distributions
|
# Binary Distributions
|
||||||
|
|
||||||
Binary distributions, which include all files necessary to build a CEF-based application, are available on the [Downloads](http://opensource.spotify.com/cefbuilds/index.html) page. Binary distributions are stand-alone and do not require the download of CEF or Chromium source code. Symbol files for debugging binary distributions of libcef can also be downloaded from the above links.
|
Binary distributions, which include all files necessary to build a CEF-based application, are available on the [Downloads](https://cef-builds.spotifycdn.com/index.html) page. Binary distributions are stand-alone and do not require the download of CEF or Chromium source code. Symbol files for debugging binary distributions of libcef can also be downloaded from the above links.
|
||||||
|
|
||||||
# Source Distributions
|
# Source Distributions
|
||||||
|
|
||||||
@@ -45,15 +45,12 @@ The base CEF framework includes support for the C and C++ programming languages.
|
|||||||
|
|
||||||
* .Net (CEF3) - https://github.com/cefsharp/CefSharp
|
* .Net (CEF3) - https://github.com/cefsharp/CefSharp
|
||||||
* .Net (CEF1) - https://bitbucket.org/fddima/cefglue
|
* .Net (CEF1) - https://bitbucket.org/fddima/cefglue
|
||||||
* .Net/Mono (CEF3) - https://bitbucket.org/xilium/xilium.cefglue
|
* .Net/Mono (CEF3) - https://gitlab.com/xiliumhq/chromiumembedded/cefglue
|
||||||
* .Net (CEF3) - https://bitbucket.org/chromiumfx/chromiumfx
|
* Delphi - https://github.com/hgourvest/dcef3
|
||||||
* Delphi (CEF1) - http://code.google.com/p/delphichromiumembedded/
|
* Delphi - https://github.com/salvadordf/CEF4Delphi
|
||||||
* Delphi (CEF3) - https://github.com/hgourvest/dcef3
|
|
||||||
* Delphi (CEF3) - https://github.com/salvadordf/CEF4Delphi
|
|
||||||
* Go - https://github.com/richardwilkes/cef
|
|
||||||
* Go - https://github.com/CzarekTomczak/cef2go
|
* Go - https://github.com/CzarekTomczak/cef2go
|
||||||
|
* Go - https://github.com/energye/energy
|
||||||
* Java - https://bitbucket.org/chromiumembedded/java-cef
|
* Java - https://bitbucket.org/chromiumembedded/java-cef
|
||||||
* Java - http://code.google.com/p/javacef/
|
|
||||||
* Python - http://code.google.com/p/cefpython/
|
* Python - http://code.google.com/p/cefpython/
|
||||||
|
|
||||||
If you're the maintainer of a project not listed above and would like your project listed here please either post to the [CEF Forum](http://www.magpcss.org/ceforum/) or contact Marshall directly.
|
If you're the maintainer of a project not listed above and would like your project listed here please either post to the [CEF Forum](http://www.magpcss.org/ceforum/) or contact Marshall directly.
|
||||||
@@ -62,7 +59,7 @@ If you're the maintainer of a project not listed above and would like your proje
|
|||||||
|
|
||||||
CEF is still very much a work in progress. Some ways that you can help out:
|
CEF is still very much a work in progress. Some ways that you can help out:
|
||||||
|
|
||||||
\- Vote for issues in the [CEF issue tracker](https://bitbucket.org/chromiumembedded/cef/issues?status=new&status=open) that are important to you. This helps with development prioritization.
|
\- Vote for issues in the [CEF issue tracker](https://github.com/chromiumembedded/cef/issues) that are important to you. This helps with development prioritization.
|
||||||
|
|
||||||
\- Report any bugs that you find or feature requests that are important to you. Make sure to first search for existing issues before creating new ones. Please use the [CEF Forum](http://magpcss.org/ceforum) and not the issue tracker for usage questions. Each CEF issue should:
|
\- Report any bugs that you find or feature requests that are important to you. Make sure to first search for existing issues before creating new ones. Please use the [CEF Forum](http://magpcss.org/ceforum) and not the issue tracker for usage questions. Each CEF issue should:
|
||||||
|
|
||||||
@@ -73,7 +70,7 @@ CEF is still very much a work in progress. Some ways that you can help out:
|
|||||||
|
|
||||||
\- Write unit tests for new or existing functionality.
|
\- Write unit tests for new or existing functionality.
|
||||||
|
|
||||||
\- Pull requests and patches are welcome. View open issues in the [CEF issue tracker](https://bitbucket.org/chromiumembedded/cef/issues?status=new&status=open) or search for TODO(cef) in the source code for ideas.
|
\- Pull requests and patches are welcome. View open issues in the [CEF issue tracker](https://github.com/chromiumembedded/cef/issues) or search for TODO(cef) in the source code for ideas.
|
||||||
|
|
||||||
If you would like to contribute source code changes to CEF please follow the below guidelines:
|
If you would like to contribute source code changes to CEF please follow the below guidelines:
|
||||||
|
|
||||||
@@ -82,6 +79,6 @@ If you would like to contribute source code changes to CEF please follow the bel
|
|||||||
\- Submit a [pull request](https://bitbucket.org/chromiumembedded/cef/wiki/ContributingWithGit) or create a patch with your changes and attach it to the CEF issue. Changes should:
|
\- Submit a [pull request](https://bitbucket.org/chromiumembedded/cef/wiki/ContributingWithGit) or create a patch with your changes and attach it to the CEF issue. Changes should:
|
||||||
|
|
||||||
* Be submitted against the current [CEF master branch](https://bitbucket.org/chromiumembedded/cef/src/?at=master) unless explicitly fixing a bug in a CEF release branch.
|
* Be submitted against the current [CEF master branch](https://bitbucket.org/chromiumembedded/cef/src/?at=master) unless explicitly fixing a bug in a CEF release branch.
|
||||||
* Follow the style of existing CEF source files. In general CEF uses the [Chromium coding style](http://www.chromium.org/developers/coding-style).
|
* Follow the style of existing CEF source files. In general CEF uses the [Chromium C++ style guide](https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md).
|
||||||
* Include new or modified unit tests as appropriate to the functionality.
|
* Include new or modified unit tests as appropriate to the functionality.
|
||||||
* Not include unnecessary or unrelated changes.
|
* Not include unnecessary or unrelated changes.
|
||||||
|
|||||||
8
bazel/BUILD.bazel
Normal file
8
bazel/BUILD.bazel
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
# Allow access from targets in other packages.
|
||||||
|
package(default_visibility = [
|
||||||
|
"//visibility:public",
|
||||||
|
])
|
||||||
65
bazel/copy_filegroups.bzl
Normal file
65
bazel/copy_filegroups.bzl
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
def _copy_filegroups_impl(ctx):
|
||||||
|
inputs = ctx.files.filegroups
|
||||||
|
remove_prefixes = ctx.attr.remove_prefixes
|
||||||
|
add_prefix = ctx.attr.add_prefix
|
||||||
|
|
||||||
|
outputs = []
|
||||||
|
for f in inputs:
|
||||||
|
relative_path = f.path
|
||||||
|
if relative_path.startswith("external/"):
|
||||||
|
# Remove the "external/<repo>" component, if any.
|
||||||
|
relative_path = "/".join(relative_path.split("/")[2:])
|
||||||
|
|
||||||
|
for prefix in remove_prefixes:
|
||||||
|
# Add trailing forward slash if necessary.
|
||||||
|
if prefix[-1] != "/":
|
||||||
|
prefix += "/"
|
||||||
|
if len(prefix) > 0 and relative_path.startswith(prefix):
|
||||||
|
relative_path = relative_path[len(prefix):]
|
||||||
|
break
|
||||||
|
|
||||||
|
if len(add_prefix) > 0:
|
||||||
|
# Add trailing forward slash if necessary.
|
||||||
|
if add_prefix[-1] != "/":
|
||||||
|
add_prefix += "/"
|
||||||
|
relative_path = add_prefix + relative_path
|
||||||
|
|
||||||
|
out = ctx.actions.declare_file(relative_path)
|
||||||
|
outputs.append(out)
|
||||||
|
|
||||||
|
if relative_path.find("/") > 0:
|
||||||
|
command="mkdir -p $(dirname {}) && cp {} {}".format(out.path, f.path, out.path)
|
||||||
|
else:
|
||||||
|
command="cp {} {}".format(f.path, out.path)
|
||||||
|
|
||||||
|
ctx.actions.run_shell(
|
||||||
|
outputs=[out],
|
||||||
|
inputs=depset([f]),
|
||||||
|
command=command
|
||||||
|
)
|
||||||
|
|
||||||
|
# Small sanity check
|
||||||
|
if len(inputs) != len(outputs):
|
||||||
|
fail("Output count should be 1-to-1 with input count.")
|
||||||
|
|
||||||
|
return DefaultInfo(
|
||||||
|
files=depset(outputs),
|
||||||
|
runfiles=ctx.runfiles(files=outputs)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Allows the file contents of |filegroups| to be copied next to a cc_binary
|
||||||
|
# target via the |data| attribute.
|
||||||
|
# Implementation based on https://stackoverflow.com/a/57983629
|
||||||
|
copy_filegroups = rule(
|
||||||
|
implementation=_copy_filegroups_impl,
|
||||||
|
attrs={
|
||||||
|
"filegroups": attr.label_list(),
|
||||||
|
"remove_prefixes": attr.string_list(default = []),
|
||||||
|
"add_prefix": attr.string(default = ""),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
90
bazel/library_helpers.bzl
Normal file
90
bazel/library_helpers.bzl
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
load("//bazel/win:variables.bzl",
|
||||||
|
WIN_COMMON_COPTS="COMMON_COPTS",
|
||||||
|
WIN_COMMON_COPTS_RELEASE="COMMON_COPTS_RELEASE",
|
||||||
|
WIN_COMMON_COPTS_DEBUG="COMMON_COPTS_DEBUG",
|
||||||
|
WIN_COMMON_DEFINES="COMMON_DEFINES",
|
||||||
|
WIN_COMMON_DEFINES_RELEASE="COMMON_DEFINES_RELEASE",
|
||||||
|
WIN_COMMON_DEFINES_DEBUG="COMMON_DEFINES_DEBUG")
|
||||||
|
load("//bazel/linux:variables.bzl",
|
||||||
|
LINUX_COMMON_COPTS="COMMON_COPTS",
|
||||||
|
LINUX_COMMON_COPTS_RELEASE="COMMON_COPTS_RELEASE",
|
||||||
|
LINUX_COMMON_COPTS_DEBUG="COMMON_COPTS_DEBUG",
|
||||||
|
LINUX_COMMON_DEFINES="COMMON_DEFINES",
|
||||||
|
LINUX_COMMON_DEFINES_RELEASE="COMMON_DEFINES_RELEASE",
|
||||||
|
LINUX_COMMON_DEFINES_DEBUG="COMMON_DEFINES_DEBUG")
|
||||||
|
load("//bazel/mac:variables.bzl",
|
||||||
|
MAC_COMMON_COPTS="COMMON_COPTS",
|
||||||
|
MAC_COMMON_COPTS_RELEASE="COMMON_COPTS_RELEASE",
|
||||||
|
MAC_COMMON_COPTS_DEBUG="COMMON_COPTS_DEBUG")
|
||||||
|
load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library")
|
||||||
|
|
||||||
|
def declare_cc_library(copts=[], local_defines=[], **kwargs):
|
||||||
|
"""
|
||||||
|
cc_library wrapper that applies common copts and local_defines.
|
||||||
|
"""
|
||||||
|
# NOTE: objc_library does not support local_defines on MacOS, so on
|
||||||
|
# that platform we put the defines in copts instead.
|
||||||
|
cc_library(
|
||||||
|
copts = select({
|
||||||
|
"@platforms//os:windows": WIN_COMMON_COPTS,
|
||||||
|
"@platforms//os:linux": LINUX_COMMON_COPTS,
|
||||||
|
"@platforms//os:macos": MAC_COMMON_COPTS,
|
||||||
|
"//conditions:default": None,
|
||||||
|
}) + select({
|
||||||
|
"@cef//:windows_opt": WIN_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:windows_dbg": WIN_COMMON_COPTS_DEBUG,
|
||||||
|
"@cef//:windows_fastbuild": WIN_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:linux_opt": LINUX_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:linux_dbg": LINUX_COMMON_COPTS_DEBUG,
|
||||||
|
"@cef//:linux_fastbuild": LINUX_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:macos_opt": MAC_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:macos_dbg": MAC_COMMON_COPTS_DEBUG,
|
||||||
|
"@cef//:macos_fastbuild": MAC_COMMON_COPTS_RELEASE,
|
||||||
|
"//conditions:default": None,
|
||||||
|
}) + copts,
|
||||||
|
local_defines = select({
|
||||||
|
"@platforms//os:windows": WIN_COMMON_DEFINES,
|
||||||
|
"@platforms//os:linux": LINUX_COMMON_DEFINES,
|
||||||
|
"//conditions:default": None,
|
||||||
|
}) + select({
|
||||||
|
"@cef//:windows_opt": WIN_COMMON_DEFINES_RELEASE,
|
||||||
|
"@cef//:windows_dbg": WIN_COMMON_DEFINES_DEBUG,
|
||||||
|
"@cef//:windows_fastbuild": WIN_COMMON_DEFINES_RELEASE,
|
||||||
|
"@cef//:linux_opt": LINUX_COMMON_DEFINES_RELEASE,
|
||||||
|
"@cef//:linux_dbg": LINUX_COMMON_DEFINES_DEBUG,
|
||||||
|
"@cef//:linux_fastbuild": LINUX_COMMON_DEFINES_RELEASE,
|
||||||
|
"//conditions:default": None,
|
||||||
|
}) + local_defines,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
def declare_objc_library(copts=[], **kwargs):
|
||||||
|
"""
|
||||||
|
objc_library wrapper that applies common copts.
|
||||||
|
"""
|
||||||
|
# NOTE: objc_library does not support local_defines on MacOS, so on
|
||||||
|
# that platform we put the defines in copts instead.
|
||||||
|
objc_library(
|
||||||
|
copts = select({
|
||||||
|
"@platforms//os:windows": WIN_COMMON_COPTS,
|
||||||
|
"@platforms//os:linux": LINUX_COMMON_COPTS,
|
||||||
|
"@platforms//os:macos": MAC_COMMON_COPTS,
|
||||||
|
"//conditions:default": None,
|
||||||
|
}) + select({
|
||||||
|
"@cef//:windows_opt": WIN_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:windows_dbg": WIN_COMMON_COPTS_DEBUG,
|
||||||
|
"@cef//:windows_fastbuild": WIN_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:linux_opt": LINUX_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:linux_dbg": LINUX_COMMON_COPTS_DEBUG,
|
||||||
|
"@cef//:linux_fastbuild": LINUX_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:macos_opt": MAC_COMMON_COPTS_RELEASE,
|
||||||
|
"@cef//:macos_dbg": MAC_COMMON_COPTS_DEBUG,
|
||||||
|
"@cef//:macos_fastbuild": MAC_COMMON_COPTS_RELEASE,
|
||||||
|
"//conditions:default": None,
|
||||||
|
}) + copts,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
8
bazel/linux/BUILD.bazel
Executable file
8
bazel/linux/BUILD.bazel
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
# Allow access from targets in other packages.
|
||||||
|
package(default_visibility = [
|
||||||
|
"//visibility:public",
|
||||||
|
])
|
||||||
63
bazel/linux/exe_helpers.bzl
Executable file
63
bazel/linux/exe_helpers.bzl
Executable file
@@ -0,0 +1,63 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
load("//bazel:copy_filegroups.bzl", "copy_filegroups")
|
||||||
|
load("//bazel/linux:fix_rpath.bzl", "fix_rpath")
|
||||||
|
load("//bazel/linux:variables.bzl",
|
||||||
|
"COMMON_LINKOPTS",
|
||||||
|
"COMMON_COPTS", "COMMON_COPTS_RELEASE", "COMMON_COPTS_DEBUG",
|
||||||
|
"COMMON_DEFINES", "COMMON_DEFINES_RELEASE", "COMMON_DEFINES_DEBUG")
|
||||||
|
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||||
|
|
||||||
|
def declare_exe(name, srcs=[], deps=[], linkopts=[], copts=[], local_defines=[], data=[], **kwargs):
|
||||||
|
# Copy SOs and resources into the current project.
|
||||||
|
copy_target = "{}_sos_and_resources".format(name)
|
||||||
|
copy_filegroups(
|
||||||
|
name = copy_target,
|
||||||
|
filegroups = [
|
||||||
|
"@cef//:sos",
|
||||||
|
"@cef//:resources",
|
||||||
|
],
|
||||||
|
remove_prefixes = [
|
||||||
|
"Debug",
|
||||||
|
"Release",
|
||||||
|
"Resources",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Executable target.
|
||||||
|
binary_target = "{}_incorrect_rpath".format(name)
|
||||||
|
cc_binary(
|
||||||
|
name = binary_target,
|
||||||
|
srcs = srcs,
|
||||||
|
deps = [
|
||||||
|
"@cef//:cef_wrapper",
|
||||||
|
"@cef//:cef",
|
||||||
|
"@cef//:cef_sandbox",
|
||||||
|
] + deps,
|
||||||
|
linkopts = COMMON_LINKOPTS + linkopts,
|
||||||
|
copts = COMMON_COPTS + select({
|
||||||
|
"@cef//:linux_dbg": COMMON_COPTS_DEBUG,
|
||||||
|
"//conditions:default": COMMON_COPTS_RELEASE,
|
||||||
|
}) + copts,
|
||||||
|
local_defines = COMMON_DEFINES + select({
|
||||||
|
"@cef//:linux_dbg": COMMON_DEFINES_DEBUG,
|
||||||
|
"//conditions:default": COMMON_DEFINES_RELEASE,
|
||||||
|
}) + local_defines,
|
||||||
|
data = [
|
||||||
|
":{}".format(copy_target),
|
||||||
|
] + data,
|
||||||
|
target_compatible_with = ["@platforms//os:linux"],
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set rpath to $ORIGIN so that libraries can be loaded from next to the
|
||||||
|
# executable.
|
||||||
|
fix_rpath(
|
||||||
|
name = "{}_fixed_rpath".format(name),
|
||||||
|
src = ":{}".format(binary_target),
|
||||||
|
out = name,
|
||||||
|
target_compatible_with = ["@platforms//os:linux"],
|
||||||
|
)
|
||||||
|
|
||||||
41
bazel/linux/fix_rpath.bzl
Normal file
41
bazel/linux/fix_rpath.bzl
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
def _fix_rpath_impl(ctx):
|
||||||
|
inputs = ctx.runfiles(files = [ctx.file.src])
|
||||||
|
# Bring over 'data' dependencies from the input.
|
||||||
|
inputs = inputs.merge_all([ctx.attr.src[DefaultInfo].default_runfiles])
|
||||||
|
|
||||||
|
src = ctx.file.src.path
|
||||||
|
out = ctx.outputs.out.path
|
||||||
|
|
||||||
|
ctx.actions.run_shell(
|
||||||
|
outputs = [ctx.outputs.out],
|
||||||
|
inputs = inputs.files,
|
||||||
|
arguments = [src, out],
|
||||||
|
command = "cp $1 $2 && " +
|
||||||
|
"chmod +w $2 && " +
|
||||||
|
"patchelf --remove-rpath $2 && " +
|
||||||
|
"patchelf --set-rpath '$ORIGIN' $2"
|
||||||
|
)
|
||||||
|
|
||||||
|
return [DefaultInfo(files = depset([ctx.outputs.out]))]
|
||||||
|
|
||||||
|
# Set rpath to $ORIGIN so that libraries can be loaded from next to the
|
||||||
|
# executable. The result can be confirmed with:
|
||||||
|
# $ objdump -x ./bazel-bin/path/to/binary | grep 'R.*PATH'
|
||||||
|
#
|
||||||
|
# Alternatively, define a custom CC toolchain that overrides
|
||||||
|
# 'runtime_library_search_directories'.
|
||||||
|
#
|
||||||
|
# This rule requires preinstallation of the patchelf package:
|
||||||
|
# $ sudo apt install patchelf
|
||||||
|
fix_rpath = rule(
|
||||||
|
implementation = _fix_rpath_impl,
|
||||||
|
attrs = {
|
||||||
|
"src": attr.label(allow_single_file = True),
|
||||||
|
"out": attr.output(mandatory = True),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
7
bazel/linux/pkg_config/BUILD.bazel
Normal file
7
bazel/linux/pkg_config/BUILD.bazel
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
|
exports_files([
|
||||||
|
"pkg_config.bzl",
|
||||||
|
"BUILD.tmpl",
|
||||||
|
])
|
||||||
|
|
||||||
32
bazel/linux/pkg_config/BUILD.tmpl
Normal file
32
bazel/linux/pkg_config/BUILD.tmpl
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# vi: ft=bzl
|
||||||
|
package(default_visibility = ["//visibility:private"])
|
||||||
|
|
||||||
|
_imports = [p[:len(p)-2] for p in glob(["{}/**/*.a".format(d) for d in [%{deps}]])]
|
||||||
|
[cc_import(
|
||||||
|
name = i.replace("/", "_"),
|
||||||
|
hdrs = glob([%{hdrs}]),
|
||||||
|
# TODO: library extension for platform.
|
||||||
|
static_library = "{}.a".format(i),
|
||||||
|
shared_library = "{}.dylib".format(i),
|
||||||
|
) for i in _imports]
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "internal_lib",
|
||||||
|
hdrs = glob([%{hdrs}]),
|
||||||
|
copts = [%{copts}],
|
||||||
|
includes = [%{includes}],
|
||||||
|
linkopts = [%{linkopts}],
|
||||||
|
deps = [(":" + i.replace("/", "_")) for i in _imports],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "lib",
|
||||||
|
hdrs = glob(["%{strip_include}/**/*.h"]),
|
||||||
|
copts = [%{extra_copts}],
|
||||||
|
linkopts = [%{extra_linkopts}],
|
||||||
|
deps = [":internal_lib"] + [%{extra_deps}],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
strip_include_prefix = "%{strip_include}",
|
||||||
|
include_prefix = "%{include_prefix}",
|
||||||
|
)
|
||||||
|
|
||||||
11
bazel/linux/pkg_config/README.cef
Normal file
11
bazel/linux/pkg_config/README.cef
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
Name: pkg_config
|
||||||
|
URL: https://github.com/cherrry/bazel_pkg_config
|
||||||
|
Version: 284219a
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Bazel rules for pkg-config tools.
|
||||||
|
|
||||||
|
CEF-specific changes:
|
||||||
|
- Fix failure with duplicate symlinks.
|
||||||
|
- Remove `--static` flag from pkg-config invocation.
|
||||||
|
|
||||||
2
bazel/linux/pkg_config/WORKSPACE
Normal file
2
bazel/linux/pkg_config/WORKSPACE
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
workspace(name = "pkg_config")
|
||||||
|
|
||||||
194
bazel/linux/pkg_config/pkg_config.bzl
Normal file
194
bazel/linux/pkg_config/pkg_config.bzl
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
def _success(value):
|
||||||
|
return struct(error = None, value = value)
|
||||||
|
|
||||||
|
def _error(message):
|
||||||
|
return struct(error = message, value = None)
|
||||||
|
|
||||||
|
def _split(result, delimeter = " "):
|
||||||
|
if result.error != None:
|
||||||
|
return result
|
||||||
|
return _success([arg for arg in result.value.strip().split(delimeter) if arg])
|
||||||
|
|
||||||
|
def _find_binary(ctx, binary_name):
|
||||||
|
binary = ctx.which(binary_name)
|
||||||
|
if binary == None:
|
||||||
|
return _error("Unable to find binary: {}".format(binary_name))
|
||||||
|
return _success(binary)
|
||||||
|
|
||||||
|
def _execute(ctx, binary, args):
|
||||||
|
result = ctx.execute([binary] + args)
|
||||||
|
if result.return_code != 0:
|
||||||
|
return _error("Failed execute {} {}".format(binary, args))
|
||||||
|
return _success(result.stdout)
|
||||||
|
|
||||||
|
def _pkg_config(ctx, pkg_config, pkg_name, args):
|
||||||
|
return _execute(ctx, pkg_config, [pkg_name] + args)
|
||||||
|
|
||||||
|
def _check(ctx, pkg_config, pkg_name):
|
||||||
|
exist = _pkg_config(ctx, pkg_config, pkg_name, ["--exists"])
|
||||||
|
if exist.error != None:
|
||||||
|
return _error("Package {} does not exist".format(pkg_name))
|
||||||
|
|
||||||
|
if ctx.attr.version != "":
|
||||||
|
version = _pkg_config(ctx, pkg_config, pkg_name, ["--exact-version", ctx.attr.version])
|
||||||
|
if version.error != None:
|
||||||
|
return _error("Require {} version = {}".format(pkg_name, ctx.attr.version))
|
||||||
|
|
||||||
|
if ctx.attr.min_version != "":
|
||||||
|
version = _pkg_config(ctx, pkg_config, pkg_name, ["--atleast-version", ctx.attr.min_version])
|
||||||
|
if version.error != None:
|
||||||
|
return _error("Require {} version >= {}".format(pkg_name, ctx.attr.min_version))
|
||||||
|
|
||||||
|
if ctx.attr.max_version != "":
|
||||||
|
version = _pkg_config(ctx, pkg_config, pkg_name, ["--max-version", ctx.attr.max_version])
|
||||||
|
if version.error != None:
|
||||||
|
return _error("Require {} version <= {}".format(pkg_name, ctx.attr.max_version))
|
||||||
|
|
||||||
|
return _success(None)
|
||||||
|
|
||||||
|
def _extract_prefix(flags, prefix, strip = True):
|
||||||
|
stripped, remain = [], []
|
||||||
|
for arg in flags:
|
||||||
|
if arg.startswith(prefix):
|
||||||
|
if strip:
|
||||||
|
stripped += [arg[len(prefix):]]
|
||||||
|
else:
|
||||||
|
stripped += [arg]
|
||||||
|
else:
|
||||||
|
remain += [arg]
|
||||||
|
return stripped, remain
|
||||||
|
|
||||||
|
def _includes(ctx, pkg_config, pkg_name):
|
||||||
|
includes = _split(_pkg_config(ctx, pkg_config, pkg_name, ["--cflags-only-I"]))
|
||||||
|
if includes.error != None:
|
||||||
|
return includes
|
||||||
|
includes, unused = _extract_prefix(includes.value, "-I", strip = True)
|
||||||
|
return _success(includes)
|
||||||
|
|
||||||
|
def _copts(ctx, pkg_config, pkg_name):
|
||||||
|
return _split(_pkg_config(ctx, pkg_config, pkg_name, [
|
||||||
|
"--cflags-only-other",
|
||||||
|
"--libs-only-L",
|
||||||
|
]))
|
||||||
|
|
||||||
|
def _linkopts(ctx, pkg_config, pkg_name):
|
||||||
|
return _split(_pkg_config(ctx, pkg_config, pkg_name, [
|
||||||
|
"--libs-only-other",
|
||||||
|
"--libs-only-l",
|
||||||
|
]))
|
||||||
|
|
||||||
|
def _ignore_opts(opts, ignore_opts):
|
||||||
|
remain = []
|
||||||
|
for opt in opts:
|
||||||
|
if opt not in ignore_opts:
|
||||||
|
remain += [opt]
|
||||||
|
return remain
|
||||||
|
|
||||||
|
def _symlinks(ctx, basename, srcpaths):
|
||||||
|
result = []
|
||||||
|
root = ctx.path("")
|
||||||
|
base = root.get_child(basename)
|
||||||
|
rootlen = len(str(base)) - len(basename)
|
||||||
|
for src in [ctx.path(p) for p in srcpaths]:
|
||||||
|
dest = base.get_child(src.basename)
|
||||||
|
if not dest.exists:
|
||||||
|
ctx.symlink(src, dest)
|
||||||
|
result += [str(dest)[rootlen:]]
|
||||||
|
return result
|
||||||
|
|
||||||
|
def _deps(ctx, pkg_config, pkg_name):
|
||||||
|
deps = _split(_pkg_config(ctx, pkg_config, pkg_name, [
|
||||||
|
"--libs-only-L",
|
||||||
|
"--static",
|
||||||
|
]))
|
||||||
|
if deps.error != None:
|
||||||
|
return deps
|
||||||
|
deps, unused = _extract_prefix(deps.value, "-L", strip = True)
|
||||||
|
result = []
|
||||||
|
for dep in {dep: True for dep in deps}.keys():
|
||||||
|
base = "deps_" + dep.replace("/", "_").replace(".", "_")
|
||||||
|
result += _symlinks(ctx, base, [dep])
|
||||||
|
return _success(result)
|
||||||
|
|
||||||
|
def _fmt_array(array):
|
||||||
|
return ",".join(['"{}"'.format(a) for a in array])
|
||||||
|
|
||||||
|
def _fmt_glob(array):
|
||||||
|
return _fmt_array(["{}/**/*.h".format(a) for a in array])
|
||||||
|
|
||||||
|
def _pkg_config_impl(ctx):
|
||||||
|
pkg_name = ctx.attr.pkg_name
|
||||||
|
if pkg_name == "":
|
||||||
|
pkg_name = ctx.attr.name
|
||||||
|
|
||||||
|
pkg_config = _find_binary(ctx, "pkg-config")
|
||||||
|
if pkg_config.error != None:
|
||||||
|
return pkg_config
|
||||||
|
pkg_config = pkg_config.value
|
||||||
|
|
||||||
|
check = _check(ctx, pkg_config, pkg_name)
|
||||||
|
if check.error != None:
|
||||||
|
return check
|
||||||
|
|
||||||
|
includes = _includes(ctx, pkg_config, pkg_name)
|
||||||
|
if includes.error != None:
|
||||||
|
return includes
|
||||||
|
includes = includes.value
|
||||||
|
includes = _symlinks(ctx, "includes", includes)
|
||||||
|
strip_include = "includes"
|
||||||
|
if len(includes) == 1:
|
||||||
|
strip_include = includes[0]
|
||||||
|
if ctx.attr.strip_include != "":
|
||||||
|
strip_include += "/" + ctx.attr.strip_include
|
||||||
|
|
||||||
|
ignore_opts = ctx.attr.ignore_opts
|
||||||
|
copts = _copts(ctx, pkg_config, pkg_name)
|
||||||
|
if copts.error != None:
|
||||||
|
return copts
|
||||||
|
copts = _ignore_opts(copts.value, ignore_opts)
|
||||||
|
|
||||||
|
linkopts = _linkopts(ctx, pkg_config, pkg_name)
|
||||||
|
if linkopts.error != None:
|
||||||
|
return linkopts
|
||||||
|
linkopts = _ignore_opts(linkopts.value, ignore_opts)
|
||||||
|
|
||||||
|
deps = _deps(ctx, pkg_config, pkg_name)
|
||||||
|
if deps.error != None:
|
||||||
|
return deps
|
||||||
|
deps = deps.value
|
||||||
|
|
||||||
|
include_prefix = ctx.attr.name
|
||||||
|
if ctx.attr.include_prefix != "":
|
||||||
|
include_prefix = ctx.attr.include_prefix + "/" + ctx.attr.name
|
||||||
|
|
||||||
|
build = ctx.template("BUILD", Label("//:BUILD.tmpl"), substitutions = {
|
||||||
|
"%{name}": ctx.attr.name,
|
||||||
|
"%{hdrs}": _fmt_glob(includes),
|
||||||
|
"%{includes}": _fmt_array(includes),
|
||||||
|
"%{copts}": _fmt_array(copts),
|
||||||
|
"%{extra_copts}": _fmt_array(ctx.attr.copts),
|
||||||
|
"%{deps}": _fmt_array(deps),
|
||||||
|
"%{extra_deps}": _fmt_array(ctx.attr.deps),
|
||||||
|
"%{linkopts}": _fmt_array(linkopts),
|
||||||
|
"%{extra_linkopts}": _fmt_array(ctx.attr.linkopts),
|
||||||
|
"%{strip_include}": strip_include,
|
||||||
|
"%{include_prefix}": include_prefix,
|
||||||
|
}, executable = False)
|
||||||
|
|
||||||
|
pkg_config = repository_rule(
|
||||||
|
attrs = {
|
||||||
|
"pkg_name": attr.string(doc = "Package name for pkg-config query, default to name."),
|
||||||
|
"include_prefix": attr.string(doc = "Additional prefix when including file, e.g. third_party. Compatible with strip_include option to produce desired include paths."),
|
||||||
|
"strip_include": attr.string(doc = "Strip prefix when including file, e.g. libs, files not included will be invisible. Compatible with include_prefix option to produce desired include paths."),
|
||||||
|
"version": attr.string(doc = "Exact package version."),
|
||||||
|
"min_version": attr.string(doc = "Minimum package version."),
|
||||||
|
"max_version": attr.string(doc = "Maximum package version."),
|
||||||
|
"deps": attr.string_list(doc = "Dependency targets."),
|
||||||
|
"linkopts": attr.string_list(doc = "Extra linkopts value."),
|
||||||
|
"copts": attr.string_list(doc = "Extra copts value."),
|
||||||
|
"ignore_opts": attr.string_list(doc = "Ignore listed opts in copts or linkopts."),
|
||||||
|
},
|
||||||
|
local = True,
|
||||||
|
implementation = _pkg_config_impl,
|
||||||
|
)
|
||||||
|
|
||||||
68
bazel/linux/variables.bzl
Executable file
68
bazel/linux/variables.bzl
Executable file
@@ -0,0 +1,68 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#
|
||||||
|
# Distribution SOs.
|
||||||
|
#
|
||||||
|
|
||||||
|
SOS = [
|
||||||
|
"libcef.so",
|
||||||
|
"libEGL.so",
|
||||||
|
"libGLESv2.so",
|
||||||
|
"libvk_swiftshader.so",
|
||||||
|
"libvulkan.so.1",
|
||||||
|
]
|
||||||
|
|
||||||
|
#
|
||||||
|
# Common 'linkopts' for cc_binary targets.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Standard link libraries.
|
||||||
|
STANDARD_LIBS = [
|
||||||
|
"X11",
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_LINKOPTS_DEBUG = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_LINKOPTS_RELEASE = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_LINKOPTS = [
|
||||||
|
"-l{}".format(lib) for lib in STANDARD_LIBS
|
||||||
|
] + select({
|
||||||
|
"@cef//:linux_dbg": COMMON_LINKOPTS_DEBUG,
|
||||||
|
"//conditions:default": COMMON_LINKOPTS_RELEASE,
|
||||||
|
})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Common 'copts' for cc_libary and cc_binary targets.
|
||||||
|
#
|
||||||
|
|
||||||
|
COMMON_COPTS = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_COPTS_DEBUG = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_COPTS_RELEASE = [
|
||||||
|
]
|
||||||
|
|
||||||
|
#
|
||||||
|
# Common 'defines' for cc_libary targets.
|
||||||
|
#
|
||||||
|
|
||||||
|
COMMON_DEFINES = [
|
||||||
|
# Used by apps to test if the sandbox is enabled
|
||||||
|
"CEF_USE_SANDBOX",
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_DEFINES_DEBUG = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_DEFINES_RELEASE = [
|
||||||
|
# Not a debug build
|
||||||
|
"NDEBUG",
|
||||||
|
]
|
||||||
|
|
||||||
8
bazel/mac/BUILD.bazel
Normal file
8
bazel/mac/BUILD.bazel
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
# Allow access from targets in other packages.
|
||||||
|
package(default_visibility = [
|
||||||
|
"//visibility:public",
|
||||||
|
])
|
||||||
113
bazel/mac/app_helpers.bzl
Normal file
113
bazel/mac/app_helpers.bzl
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
|
||||||
|
load("@build_bazel_rules_apple//apple:macos.bzl", "macos_application")
|
||||||
|
load("//bazel:variables.bzl", "VERSION_PLIST")
|
||||||
|
load("//bazel/mac:variables.bzl",
|
||||||
|
"MACOS_DEPLOYMENT_TARGET",
|
||||||
|
"MACOS_BUNDLE_ID_BASE",
|
||||||
|
"CEF_FRAMEWORK_NAME",
|
||||||
|
"COMMON_LINKOPTS")
|
||||||
|
|
||||||
|
def _declare_helper_app(name, info_plist, deps, helper_base_name, helper_suffix, **kwargs):
|
||||||
|
"""
|
||||||
|
Creates a Helper .app target.
|
||||||
|
"""
|
||||||
|
helper_name = "{} Helper".format(name)
|
||||||
|
bundle_id_suffix = ""
|
||||||
|
|
||||||
|
if helper_suffix:
|
||||||
|
helper_name += " ({})".format(helper_suffix)
|
||||||
|
bundle_id_suffix += ".{}".format(helper_suffix.lower())
|
||||||
|
|
||||||
|
# Helper app bundle Info.plist.
|
||||||
|
expand_template(
|
||||||
|
name = "{}_InfoPList".format(helper_base_name),
|
||||||
|
template = info_plist,
|
||||||
|
out = "{}Info.plist".format(helper_base_name),
|
||||||
|
substitutions = {
|
||||||
|
"${EXECUTABLE_NAME}": helper_name,
|
||||||
|
"${PRODUCT_NAME}": name,
|
||||||
|
"${BUNDLE_ID_SUFFIX}": bundle_id_suffix,
|
||||||
|
"${VERSION_SHORT}": VERSION_PLIST,
|
||||||
|
"${VERSION_LONG}": VERSION_PLIST,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
# Helper app bundle.
|
||||||
|
macos_application(
|
||||||
|
name = helper_base_name,
|
||||||
|
bundle_name = helper_name,
|
||||||
|
bundle_id = "{}.{}.helper{}".format(MACOS_BUNDLE_ID_BASE, name.lower(), bundle_id_suffix),
|
||||||
|
infoplists = [":{}_InfoPList".format(helper_base_name)],
|
||||||
|
minimum_os_version = MACOS_DEPLOYMENT_TARGET,
|
||||||
|
deps = [
|
||||||
|
"@cef//:cef_sandbox",
|
||||||
|
] + deps,
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
HELPERS = {
|
||||||
|
"HelperBase": "",
|
||||||
|
"HelperAlerts": "Alerts",
|
||||||
|
"HelperGPU": "GPU",
|
||||||
|
"HelperPlugin": "Plugin",
|
||||||
|
"HelperRenderer": "Renderer",
|
||||||
|
}
|
||||||
|
|
||||||
|
def declare_all_helper_apps(name, info_plist, deps, **kwargs):
|
||||||
|
"""
|
||||||
|
Creates all Helper .app targets.
|
||||||
|
"""
|
||||||
|
[_declare_helper_app(
|
||||||
|
name = name,
|
||||||
|
info_plist = info_plist,
|
||||||
|
deps = deps,
|
||||||
|
helper_base_name = h,
|
||||||
|
helper_suffix = v,
|
||||||
|
**kwargs,
|
||||||
|
) for h, v in HELPERS.items()]
|
||||||
|
|
||||||
|
def declare_main_app(name, info_plist, deps, resources, linkopts=[], **kwargs):
|
||||||
|
"""
|
||||||
|
Creates the main .app target.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Main app bundle Info.plist.
|
||||||
|
expand_template(
|
||||||
|
name = "InfoPList",
|
||||||
|
template = info_plist,
|
||||||
|
out = "Info.plist",
|
||||||
|
substitutions = {
|
||||||
|
"${EXECUTABLE_NAME}": name,
|
||||||
|
"${PRODUCT_NAME}": name,
|
||||||
|
"${VERSION_SHORT}": VERSION_PLIST,
|
||||||
|
"${VERSION_LONG}": VERSION_PLIST,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
# Main app bindle.
|
||||||
|
macos_application(
|
||||||
|
name = name,
|
||||||
|
additional_contents = {
|
||||||
|
":HelperBase": "Frameworks",
|
||||||
|
":HelperAlerts": "Frameworks",
|
||||||
|
":HelperGPU": "Frameworks",
|
||||||
|
":HelperPlugin": "Frameworks",
|
||||||
|
":HelperRenderer": "Frameworks",
|
||||||
|
"@cef//:cef_framework": "Frameworks/{}.framework".format(CEF_FRAMEWORK_NAME),
|
||||||
|
},
|
||||||
|
bundle_name = name,
|
||||||
|
bundle_id = "{}.{}".format(MACOS_BUNDLE_ID_BASE, name.lower()),
|
||||||
|
infoplists = [":InfoPList"],
|
||||||
|
linkopts = COMMON_LINKOPTS + linkopts,
|
||||||
|
minimum_os_version = MACOS_DEPLOYMENT_TARGET,
|
||||||
|
resources = resources,
|
||||||
|
target_compatible_with = [
|
||||||
|
"@platforms//os:macos",
|
||||||
|
],
|
||||||
|
deps = deps,
|
||||||
|
**kwargs,
|
||||||
|
)
|
||||||
52
bazel/mac/variables.bzl
Normal file
52
bazel/mac/variables.bzl
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
MACOS_DEPLOYMENT_TARGET="11.0"
|
||||||
|
MACOS_BUNDLE_ID_BASE="org.cef"
|
||||||
|
CEF_FRAMEWORK_NAME="Chromium Embedded Framework"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Common 'linkopts' for macos_application targets.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Standard link frameworks.
|
||||||
|
STANDARD_FRAMEWORKS = [
|
||||||
|
"AppKit",
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_LINKOPTS_DEBUG = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_LINKOPTS_RELEASE = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_LINKOPTS = [
|
||||||
|
"-framework {}".format(lib) for lib in STANDARD_FRAMEWORKS
|
||||||
|
] + select({
|
||||||
|
"@cef//:macos_dbg": COMMON_LINKOPTS_DEBUG,
|
||||||
|
"//conditions:default": COMMON_LINKOPTS_RELEASE,
|
||||||
|
})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Common 'copts' for cc_libary, objc_library and macos_application targets.
|
||||||
|
# We include defines in 'copts' because objc_library does not support
|
||||||
|
# 'local_defines'. See https://github.com/bazelbuild/bazel/issues/17482.
|
||||||
|
#
|
||||||
|
|
||||||
|
COMMON_COPTS = [
|
||||||
|
"-Wno-undefined-var-template",
|
||||||
|
"-Wno-missing-field-initializers",
|
||||||
|
"-Wno-deprecated-copy",
|
||||||
|
|
||||||
|
# Used by apps to test if the sandbox is enabled
|
||||||
|
"-DCEF_USE_SANDBOX",
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_COPTS_DEBUG = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_COPTS_RELEASE = [
|
||||||
|
# Not a debug build
|
||||||
|
"-DNDEBUG",
|
||||||
|
]
|
||||||
8
bazel/win/BUILD.bazel
Normal file
8
bazel/win/BUILD.bazel
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
# Allow access from targets in other packages.
|
||||||
|
package(default_visibility = [
|
||||||
|
"//visibility:public",
|
||||||
|
])
|
||||||
33
bazel/win/cc_env.bzl
Normal file
33
bazel/win/cc_env.bzl
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", _use_cpp_toolchain="use_cpp_toolchain")
|
||||||
|
load("@rules_cc//cc:action_names.bzl", "CPP_COMPILE_ACTION_NAME")
|
||||||
|
|
||||||
|
# Since we need windows.h and other headers, we should ensure we have the same
|
||||||
|
# development environment as a regular cl.exe call. So use the current toolchain
|
||||||
|
# to grab environment variables to feed into the actual rc.exe call
|
||||||
|
# Much of this is taken from:
|
||||||
|
# https://github.com/bazelbuild/rules_cc/blob/main/examples/my_c_archive/my_c_archive.bzl
|
||||||
|
def collect_compilation_env(ctx):
|
||||||
|
cc_toolchain = find_cpp_toolchain(ctx)
|
||||||
|
feature_configuration = cc_common.configure_features(
|
||||||
|
ctx = ctx,
|
||||||
|
cc_toolchain = cc_toolchain,
|
||||||
|
requested_features = ctx.features,
|
||||||
|
unsupported_features = ctx.disabled_features,
|
||||||
|
)
|
||||||
|
|
||||||
|
compiler_variables = cc_common.create_compile_variables(
|
||||||
|
feature_configuration = feature_configuration,
|
||||||
|
cc_toolchain = cc_toolchain,
|
||||||
|
)
|
||||||
|
|
||||||
|
return cc_common.get_environment_variables(
|
||||||
|
feature_configuration = feature_configuration,
|
||||||
|
action_name = CPP_COMPILE_ACTION_NAME,
|
||||||
|
variables = compiler_variables,
|
||||||
|
)
|
||||||
|
|
||||||
|
use_cpp_toolchain=_use_cpp_toolchain
|
||||||
83
bazel/win/exe_helpers.bzl
Normal file
83
bazel/win/exe_helpers.bzl
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
load("//bazel:copy_filegroups.bzl", "copy_filegroups")
|
||||||
|
load("//bazel/win:mt.bzl", "add_manifest")
|
||||||
|
load("//bazel/win:rc.bzl", "compile_rc")
|
||||||
|
load("//bazel/win:variables.bzl",
|
||||||
|
"COMMON_LINKOPTS",
|
||||||
|
"COMMON_COPTS", "COMMON_COPTS_RELEASE", "COMMON_COPTS_DEBUG",
|
||||||
|
"COMMON_DEFINES", "COMMON_DEFINES_RELEASE", "COMMON_DEFINES_DEBUG")
|
||||||
|
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||||
|
|
||||||
|
def declare_exe(name, srcs, manifest_srcs, rc_file, resources_srcs, resources_deps=[],
|
||||||
|
deps=[], linkopts=[], copts=[], local_defines=[], data=[],
|
||||||
|
additional_linker_inputs=[], features=[], **kwargs):
|
||||||
|
# Resource file.
|
||||||
|
res_target = "{}_res".format(name)
|
||||||
|
compile_rc(
|
||||||
|
name = res_target,
|
||||||
|
rc_file = rc_file,
|
||||||
|
srcs = resources_srcs,
|
||||||
|
deps = resources_deps,
|
||||||
|
out = "{}.res".format(name),
|
||||||
|
target_compatible_with = ["@platforms//os:windows"],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Copy DLLs and resources into the current project.
|
||||||
|
copy_target = "{}_dlls_and_resources".format(name)
|
||||||
|
copy_filegroups(
|
||||||
|
name = copy_target,
|
||||||
|
filegroups = [
|
||||||
|
"@cef//:dlls",
|
||||||
|
"@cef//:resources",
|
||||||
|
],
|
||||||
|
remove_prefixes = [
|
||||||
|
"Debug",
|
||||||
|
"Release",
|
||||||
|
"Resources",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Executable target.
|
||||||
|
binary_target = "{}_no_manifest".format(name)
|
||||||
|
cc_binary(
|
||||||
|
name = binary_target,
|
||||||
|
srcs = srcs,
|
||||||
|
deps = [
|
||||||
|
"@cef//:cef_wrapper",
|
||||||
|
"@cef//:cef_sandbox",
|
||||||
|
] + deps,
|
||||||
|
linkopts = [
|
||||||
|
"$(location @cef//:cef_lib)",
|
||||||
|
"$(location :{})".format(res_target),
|
||||||
|
] + COMMON_LINKOPTS + linkopts,
|
||||||
|
copts = COMMON_COPTS + select({
|
||||||
|
"@cef//:windows_dbg": COMMON_COPTS_DEBUG,
|
||||||
|
"//conditions:default": COMMON_COPTS_RELEASE,
|
||||||
|
}) + copts,
|
||||||
|
local_defines = COMMON_DEFINES + select({
|
||||||
|
"@cef//:windows_dbg": COMMON_DEFINES_DEBUG,
|
||||||
|
"//conditions:default": COMMON_DEFINES_RELEASE,
|
||||||
|
}) + local_defines,
|
||||||
|
additional_linker_inputs = [
|
||||||
|
"@cef//:cef_lib",
|
||||||
|
":{}".format(res_target),
|
||||||
|
] + additional_linker_inputs,
|
||||||
|
data = [
|
||||||
|
":{}".format(copy_target),
|
||||||
|
] + data,
|
||||||
|
features = ["generate_pdb_file"] + features,
|
||||||
|
target_compatible_with = ["@platforms//os:windows"],
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add manifest and rename to final executable.
|
||||||
|
add_manifest(
|
||||||
|
name = name,
|
||||||
|
mt_files = manifest_srcs,
|
||||||
|
in_binary = ":{}".format(binary_target),
|
||||||
|
out_binary = "{}.exe".format(name),
|
||||||
|
target_compatible_with = ["@platforms//os:windows"],
|
||||||
|
)
|
||||||
72
bazel/win/mt.bzl
Normal file
72
bazel/win/mt.bzl
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
load("//bazel/win:cc_env.bzl", "collect_compilation_env", "use_cpp_toolchain")
|
||||||
|
|
||||||
|
# Copy exe and pdb file without tracking the destination as an output.
|
||||||
|
# Based on https://github.com/bazelbuild/bazel-skylib/blob/main/rules/private/copy_file_private.bzl
|
||||||
|
def _write_copy_cmd(ctx, src, dst):
|
||||||
|
# Most Windows binaries built with MSVC use a certain argument quoting
|
||||||
|
# scheme. Bazel uses that scheme too to quote arguments. However,
|
||||||
|
# cmd.exe uses different semantics, so Bazel's quoting is wrong here.
|
||||||
|
# To fix that we write the command to a .bat file so no command line
|
||||||
|
# quoting or escaping is required.
|
||||||
|
bat = ctx.actions.declare_file(ctx.label.name + "-cmd.bat")
|
||||||
|
src_path = src.path.replace("/", "\\")
|
||||||
|
dst_path = dst.path.replace("/", "\\")
|
||||||
|
ctx.actions.write(
|
||||||
|
output = bat,
|
||||||
|
# Do not use lib/shell.bzl's shell.quote() method, because that uses
|
||||||
|
# Bash quoting syntax, which is different from cmd.exe's syntax.
|
||||||
|
content = "@copy /Y \"%s\" \"%s\" >NUL\n@copy /Y \"%s\" \"%s\" >NUL" % (
|
||||||
|
src_path,
|
||||||
|
dst_path,
|
||||||
|
src_path.replace(".exe", ".pdb"),
|
||||||
|
dst_path.replace(".exe", ".pdb"),
|
||||||
|
),
|
||||||
|
is_executable = True,
|
||||||
|
)
|
||||||
|
return bat
|
||||||
|
|
||||||
|
def _add_mt_impl(ctx):
|
||||||
|
mt_files = ctx.files.mt_files
|
||||||
|
input = ctx.attr.in_binary[DebugPackageInfo].unstripped_file
|
||||||
|
output = ctx.outputs.out_binary
|
||||||
|
bat = _write_copy_cmd(ctx, input, output)
|
||||||
|
|
||||||
|
inputs = mt_files + [input, bat]
|
||||||
|
|
||||||
|
# Bring over 'data' dependencies from the input.
|
||||||
|
deps_inputs = ctx.runfiles(files = inputs)
|
||||||
|
deps_inputs = deps_inputs.merge_all([ctx.attr.in_binary[DefaultInfo].default_runfiles])
|
||||||
|
|
||||||
|
ctx.actions.run(
|
||||||
|
executable = ctx.executable._tool,
|
||||||
|
inputs = deps_inputs.files,
|
||||||
|
outputs = [output],
|
||||||
|
env = collect_compilation_env(ctx),
|
||||||
|
# The bat file will be executed before the tool command.
|
||||||
|
arguments = [bat.path, "-nologo", "-manifest"] + [f.path for f in mt_files] +
|
||||||
|
["-outputresource:{}".format(output.path)],
|
||||||
|
mnemonic = "AddMT"
|
||||||
|
)
|
||||||
|
|
||||||
|
return DefaultInfo(files = depset([output]))
|
||||||
|
|
||||||
|
add_manifest = rule(
|
||||||
|
implementation = _add_mt_impl,
|
||||||
|
attrs = {
|
||||||
|
"mt_files": attr.label_list(allow_files = [".manifest"]),
|
||||||
|
"in_binary": attr.label(providers = [CcInfo], allow_single_file = True),
|
||||||
|
"out_binary": attr.output(),
|
||||||
|
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
|
||||||
|
"_tool": attr.label(
|
||||||
|
default = "@winsdk//:mt_pybin",
|
||||||
|
executable = True,
|
||||||
|
cfg = "exec"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
fragments = ["cpp"],
|
||||||
|
toolchains = use_cpp_toolchain(),
|
||||||
|
)
|
||||||
50
bazel/win/rc.bzl
Normal file
50
bazel/win/rc.bzl
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
load("//bazel/win:cc_env.bzl", "collect_compilation_env", "use_cpp_toolchain")
|
||||||
|
|
||||||
|
def _compile_rc_impl(ctx):
|
||||||
|
rc_file = ctx.file.rc_file
|
||||||
|
output = ctx.outputs.out
|
||||||
|
|
||||||
|
inputs = [rc_file] + ctx.files.srcs
|
||||||
|
includes = ["/i{}/{}".format(ctx.label.package, i) for i in ctx.attr.includes]
|
||||||
|
|
||||||
|
# Grab all include paths/files required for the run
|
||||||
|
for dep in ctx.attr.deps:
|
||||||
|
comp_ctx = dep[CcInfo].compilation_context
|
||||||
|
|
||||||
|
includes += ["/i{}".format(i) for i in comp_ctx.quote_includes.to_list()]
|
||||||
|
includes += ["/i{}".format(i) for i in comp_ctx.system_includes.to_list()]
|
||||||
|
inputs += comp_ctx.headers.to_list()
|
||||||
|
|
||||||
|
ctx.actions.run(
|
||||||
|
executable = ctx.executable._tool,
|
||||||
|
inputs = inputs,
|
||||||
|
outputs = [output],
|
||||||
|
env = collect_compilation_env(ctx),
|
||||||
|
arguments = includes + ["/fo", output.path, rc_file.path],
|
||||||
|
mnemonic = "CompileRC"
|
||||||
|
)
|
||||||
|
|
||||||
|
return DefaultInfo(files = depset([output]))
|
||||||
|
|
||||||
|
compile_rc = rule(
|
||||||
|
implementation = _compile_rc_impl,
|
||||||
|
attrs = {
|
||||||
|
"rc_file": attr.label(allow_single_file = [".rc"]),
|
||||||
|
"srcs": attr.label_list(allow_files = True),
|
||||||
|
"deps": attr.label_list(providers = [CcInfo]),
|
||||||
|
"includes": attr.string_list(),
|
||||||
|
"out": attr.output(),
|
||||||
|
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
|
||||||
|
"_tool": attr.label(
|
||||||
|
default = "@winsdk//:rc_pybin",
|
||||||
|
executable = True,
|
||||||
|
cfg = "exec"
|
||||||
|
)
|
||||||
|
},
|
||||||
|
fragments = ["cpp"],
|
||||||
|
toolchains = use_cpp_toolchain(),
|
||||||
|
)
|
||||||
124
bazel/win/setup_sdk.bzl
Normal file
124
bazel/win/setup_sdk.bzl
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
load("@bazel_tools//tools/cpp:windows_cc_configure.bzl", "find_vc_path", "setup_vc_env_vars")
|
||||||
|
|
||||||
|
def _get_arch(rctx):
|
||||||
|
if rctx.os.arch == "amd64":
|
||||||
|
return "x64"
|
||||||
|
|
||||||
|
def _is_windows(rctx):
|
||||||
|
return rctx.os.name.find("windows") != -1
|
||||||
|
|
||||||
|
# Tools in the form <Target>: [<Tool>, <Other files needed for that target>]
|
||||||
|
TOOLS = {
|
||||||
|
"mt": {
|
||||||
|
"tool": "mt.exe",
|
||||||
|
"deps": [],
|
||||||
|
},
|
||||||
|
"rc": {
|
||||||
|
"tool": "rc.exe",
|
||||||
|
"deps": ["rcdll.dll"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
def _setup_tools(rctx, sdk_bin_path, sdk_metadata_path):
|
||||||
|
contents = ""
|
||||||
|
|
||||||
|
rctx.symlink(sdk_metadata_path, "VerUnionMetadata")
|
||||||
|
contents += """
|
||||||
|
exports_files(["VerUnionMetadata"])
|
||||||
|
"""
|
||||||
|
|
||||||
|
for toolname, toolcfg in TOOLS.items():
|
||||||
|
toolexec = toolcfg["tool"]
|
||||||
|
deps = toolcfg["deps"]
|
||||||
|
direct_deps = [toolexec] + deps
|
||||||
|
shared_deps = toolcfg.get("shared_deps", [])
|
||||||
|
|
||||||
|
# Symlink any tools into the right places
|
||||||
|
for dep in direct_deps:
|
||||||
|
rctx.symlink(
|
||||||
|
"{}/{}".format(sdk_bin_path, dep),
|
||||||
|
dep,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Setting up a filegroup for those dependents
|
||||||
|
contents += """
|
||||||
|
filegroup(
|
||||||
|
name = "{}_deps",
|
||||||
|
srcs = {},
|
||||||
|
)
|
||||||
|
""".format(toolname, direct_deps + shared_deps)
|
||||||
|
|
||||||
|
# Now create a wrapper for this tool that simply calls it
|
||||||
|
rctx.template(
|
||||||
|
"{}_wrapper.py".format(toolname),
|
||||||
|
Label("//bazel/win:wrapper.py.tpl"),
|
||||||
|
substitutions = {
|
||||||
|
"${binary}": toolexec,
|
||||||
|
},
|
||||||
|
executable = True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# And add that newly created wrapper to the BUILD.bazel file
|
||||||
|
contents += """
|
||||||
|
py_binary(
|
||||||
|
name = "{0}_pybin",
|
||||||
|
srcs = ["{0}_wrapper.py"],
|
||||||
|
main = "{0}_wrapper.py",
|
||||||
|
data = [
|
||||||
|
"@rules_python//python/runfiles",
|
||||||
|
":{0}_deps"
|
||||||
|
],
|
||||||
|
python_version = "PY3",
|
||||||
|
)
|
||||||
|
""".format(toolname)
|
||||||
|
|
||||||
|
return contents
|
||||||
|
|
||||||
|
def _setup_vc_debug_runtime(rctx, sdk_bin_path):
|
||||||
|
ucrtbased_dll = "ucrtbased.dll"
|
||||||
|
rctx.symlink("{}/ucrt/{}".format(sdk_bin_path, ucrtbased_dll), ucrtbased_dll)
|
||||||
|
|
||||||
|
contents = """
|
||||||
|
filegroup(
|
||||||
|
name = "vc_debug_runtime",
|
||||||
|
srcs = ["{}"],
|
||||||
|
)
|
||||||
|
""".format(ucrtbased_dll)
|
||||||
|
|
||||||
|
return contents
|
||||||
|
|
||||||
|
def _windows_sdk_impl(rctx):
|
||||||
|
# We only support Windows
|
||||||
|
if not _is_windows(rctx):
|
||||||
|
fail("This rule only supports Windows")
|
||||||
|
|
||||||
|
# Figure out where the SDK is, which is based on a registry key.
|
||||||
|
vc_path = find_vc_path(rctx)
|
||||||
|
env = setup_vc_env_vars(rctx, vc_path, envvars = ["WINDOWSSDKVERBINPATH", "WindowsSdkDir", "WindowsSDKVersion"])
|
||||||
|
sdk_bin_path = "{}{}".format(env["WINDOWSSDKVERBINPATH"], _get_arch(rctx))
|
||||||
|
sdk_metadata_path = "{}UnionMetadata/{}".format(env["WindowsSdkDir"], env["WindowsSDKVersion"])
|
||||||
|
|
||||||
|
# Start with some pre-amble
|
||||||
|
contents = """# Autogenerated by //bazel/win:sdk.bzl
|
||||||
|
load("@rules_python//python:defs.bzl", "py_binary")
|
||||||
|
|
||||||
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Handle setting up tools from our list
|
||||||
|
contents += _setup_tools(rctx, sdk_bin_path, sdk_metadata_path)
|
||||||
|
|
||||||
|
contents += _setup_vc_debug_runtime(rctx, sdk_bin_path)
|
||||||
|
|
||||||
|
rctx.file("BUILD.bazel", contents)
|
||||||
|
|
||||||
|
setup_sdk = repository_rule(
|
||||||
|
attrs = {},
|
||||||
|
local = True,
|
||||||
|
configure = True,
|
||||||
|
implementation = _windows_sdk_impl,
|
||||||
|
)
|
||||||
199
bazel/win/variables.bzl
Normal file
199
bazel/win/variables.bzl
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#
|
||||||
|
# Distribution DLLs.
|
||||||
|
#
|
||||||
|
|
||||||
|
DLLS = [
|
||||||
|
"chrome_elf.dll",
|
||||||
|
"d3dcompiler_47.dll",
|
||||||
|
"libcef.dll",
|
||||||
|
"libEGL.dll",
|
||||||
|
"libGLESv2.dll",
|
||||||
|
"vk_swiftshader.dll",
|
||||||
|
"vulkan-1.dll",
|
||||||
|
]
|
||||||
|
|
||||||
|
DLLS_X64 = [
|
||||||
|
"dxil.dll",
|
||||||
|
"dxcompiler.dll",
|
||||||
|
]
|
||||||
|
|
||||||
|
#
|
||||||
|
# Common 'linkopts' for cc_binary targets.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Windows delayload DLLs.
|
||||||
|
# Delayload most libraries as the DLLs are simply not required at startup (or
|
||||||
|
# at all, depending on the process type). Some dlls open handles when they are
|
||||||
|
# loaded, and we may not want them to be loaded in renderers or other sandboxed
|
||||||
|
# processes. Conversely, some DLLs must be loaded before sandbox lockdown. In
|
||||||
|
# unsandboxed processes they will load when first needed. The linker will
|
||||||
|
# automatically ignore anything which is not linked to the binary at all (it is
|
||||||
|
# harmless to have an unmatched /delayload). This list should be kept in sync
|
||||||
|
# with Chromium's "delayloads" target from the //build/config/win/BUILD.gn file.
|
||||||
|
DELAYLOAD_DLLS = [
|
||||||
|
"api-ms-win-core-winrt-error-l1-1-0.dll",
|
||||||
|
"api-ms-win-core-winrt-l1-1-0.dll",
|
||||||
|
"api-ms-win-core-winrt-string-l1-1-0.dll",
|
||||||
|
"advapi32.dll",
|
||||||
|
"comctl32.dll",
|
||||||
|
"comdlg32.dll",
|
||||||
|
"credui.dll",
|
||||||
|
"cryptui.dll",
|
||||||
|
"d3d11.dll",
|
||||||
|
"d3d9.dll",
|
||||||
|
"dwmapi.dll",
|
||||||
|
"dxgi.dll",
|
||||||
|
"dxva2.dll",
|
||||||
|
"esent.dll",
|
||||||
|
"gdi32.dll",
|
||||||
|
"hid.dll",
|
||||||
|
"imagehlp.dll",
|
||||||
|
"imm32.dll",
|
||||||
|
"msi.dll",
|
||||||
|
"netapi32.dll",
|
||||||
|
"ncrypt.dll",
|
||||||
|
"ole32.dll",
|
||||||
|
"oleacc.dll",
|
||||||
|
"propsys.dll",
|
||||||
|
"psapi.dll",
|
||||||
|
"rpcrt4.dll",
|
||||||
|
"rstrtmgr.dll",
|
||||||
|
"setupapi.dll",
|
||||||
|
"shell32.dll",
|
||||||
|
"shlwapi.dll",
|
||||||
|
"uiautomationcore.dll",
|
||||||
|
"urlmon.dll",
|
||||||
|
"user32.dll",
|
||||||
|
"usp10.dll",
|
||||||
|
"uxtheme.dll",
|
||||||
|
"wer.dll",
|
||||||
|
"wevtapi.dll",
|
||||||
|
"wininet.dll",
|
||||||
|
"winusb.dll",
|
||||||
|
"wsock32.dll",
|
||||||
|
"wtsapi32.dll",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Standard link libraries.
|
||||||
|
STANDARD_LIBS = [
|
||||||
|
"comctl32.lib",
|
||||||
|
"gdi32.lib",
|
||||||
|
"rpcrt4.lib",
|
||||||
|
"shlwapi.lib",
|
||||||
|
"user32.lib",
|
||||||
|
"ws2_32.lib",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Sandbox link libraries.
|
||||||
|
SANDBOX_LIBS = [
|
||||||
|
"Advapi32.lib",
|
||||||
|
"dbghelp.lib",
|
||||||
|
"Delayimp.lib",
|
||||||
|
"ntdll.lib",
|
||||||
|
"OleAut32.lib",
|
||||||
|
"PowrProf.lib",
|
||||||
|
"Propsys.lib",
|
||||||
|
"psapi.lib",
|
||||||
|
"SetupAPI.lib",
|
||||||
|
"Shcore.lib",
|
||||||
|
"Shell32.lib",
|
||||||
|
"Userenv.lib",
|
||||||
|
"version.lib",
|
||||||
|
"wbemuuid.lib",
|
||||||
|
"WindowsApp.lib",
|
||||||
|
"winmm.lib",
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_LINKOPTS_DEBUG = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_LINKOPTS_RELEASE = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_LINKOPTS = [
|
||||||
|
# No default manifest (see compile_rc target).
|
||||||
|
"/MANIFEST:NO",
|
||||||
|
# Allow 32-bit processes to access 3GB of RAM.
|
||||||
|
"/LARGEADDRESSAWARE",
|
||||||
|
# Generate Debug information.
|
||||||
|
# TODO: Remove after fixing opt builds to work without it.
|
||||||
|
"/DEBUG",
|
||||||
|
] + [
|
||||||
|
"/DELAYLOAD:{}".format(dll) for dll in DELAYLOAD_DLLS
|
||||||
|
] + [
|
||||||
|
"/DEFAULTLIB:{}".format(lib) for lib in STANDARD_LIBS
|
||||||
|
] + select({
|
||||||
|
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB minimum
|
||||||
|
# needed by CEF's main thread. This saves significant memory on threads
|
||||||
|
# (like those in the Windows thread pool, and others) whose stack size we
|
||||||
|
# can only control through this setting. The main thread (in 32-bit builds
|
||||||
|
# only) uses fibers to switch to a 4MiB stack at runtime via
|
||||||
|
# CefRunWinMainWithPreferredStackSize().
|
||||||
|
"@cef//:windows_32": ["/STACK:0x80000"],
|
||||||
|
# Increase the initial stack size to 8MiB from the default 1MiB.
|
||||||
|
"//conditions:default": ["/STACK:0x800000"],
|
||||||
|
}) + select({
|
||||||
|
"@cef//:windows_dbg": COMMON_LINKOPTS_DEBUG,
|
||||||
|
"//conditions:default": COMMON_LINKOPTS_RELEASE,
|
||||||
|
})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Common 'copts' for cc_libary and cc_binary targets.
|
||||||
|
#
|
||||||
|
|
||||||
|
COMMON_COPTS = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_COPTS_DEBUG = [
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_COPTS_RELEASE = [
|
||||||
|
]
|
||||||
|
|
||||||
|
#
|
||||||
|
# Common 'defines' for cc_libary targets.
|
||||||
|
#
|
||||||
|
|
||||||
|
COMMON_DEFINES = [
|
||||||
|
# Windows platform
|
||||||
|
"WIN32",
|
||||||
|
"_WIN32",
|
||||||
|
"_WINDOWS",
|
||||||
|
# Unicode build
|
||||||
|
"UNICODE",
|
||||||
|
"_UNICODE",
|
||||||
|
# Targeting Windows 10. We can't say `=_WIN32_WINNT_WIN10` here because
|
||||||
|
# some files do `#if WINVER < 0x0600` without including windows.h before,
|
||||||
|
# and then _WIN32_WINNT_WIN10 isn't yet known to be 0x0A00.
|
||||||
|
"WINVER=0x0A00",
|
||||||
|
"_WIN32_WINNT=0x0A00",
|
||||||
|
"NTDDI_VERSION=NTDDI_WIN10_FE",
|
||||||
|
# Use the standard's templated min/max
|
||||||
|
"NOMINMAX",
|
||||||
|
# Exclude less common API declarations
|
||||||
|
"WIN32_LEAN_AND_MEAN",
|
||||||
|
# Disable exceptions
|
||||||
|
"_HAS_EXCEPTIONS=0",
|
||||||
|
|
||||||
|
# Required by cef_sandbox.lib
|
||||||
|
"PSAPI_VERSION=1",
|
||||||
|
# Used by apps to test if the sandbox is enabled
|
||||||
|
"CEF_USE_SANDBOX",
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_DEFINES_DEBUG = [
|
||||||
|
# Required by cef_sandbox.lib
|
||||||
|
# Disable iterator debugging
|
||||||
|
"HAS_ITERATOR_DEBUGGING=0",
|
||||||
|
"_ITERATOR_DEBUG_LEVEL=0",
|
||||||
|
]
|
||||||
|
|
||||||
|
COMMON_DEFINES_RELEASE = [
|
||||||
|
# Not a debug build
|
||||||
|
"NDEBUG",
|
||||||
|
"_NDEBUG",
|
||||||
|
]
|
||||||
69
bazel/win/wrapper.py.tpl
Normal file
69
bazel/win/wrapper.py.tpl
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||||
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from rules_python.python.runfiles import runfiles
|
||||||
|
|
||||||
|
REPLACEMENTS = {
|
||||||
|
"XXX_GETCWD_XXX": os.getcwd(),
|
||||||
|
}
|
||||||
|
|
||||||
|
def replace_in_str(input):
|
||||||
|
output = input
|
||||||
|
for placeholder, replacement in REPLACEMENTS.items():
|
||||||
|
if placeholder in output:
|
||||||
|
output = output.replace(placeholder, replacement)
|
||||||
|
return output
|
||||||
|
|
||||||
|
def print_error(str):
|
||||||
|
print(str, file=sys.stderr)
|
||||||
|
|
||||||
|
r = runfiles.Create()
|
||||||
|
wrapped_binary = r.Rlocation("winsdk/${binary}")
|
||||||
|
args = list(map(replace_in_str, sys.argv[1:]))
|
||||||
|
|
||||||
|
# Optionally execute a script before tool execution.
|
||||||
|
if args[0].endswith('.bat') or args[0].endswith('.cmd'):
|
||||||
|
if sys.platform != 'win32':
|
||||||
|
raise RuntimeError("Error running bat file; unsupported platform")
|
||||||
|
|
||||||
|
# Execute the .bat file first.
|
||||||
|
bat_file = args[0].replace('/', '\\')
|
||||||
|
p = subprocess.run(
|
||||||
|
bat_file, shell=True,
|
||||||
|
stdout = subprocess.PIPE,
|
||||||
|
stderr = subprocess.STDOUT,
|
||||||
|
text=True)
|
||||||
|
if p.returncode != 0:
|
||||||
|
print_error("[Generated python wrapper] Error running bat file:")
|
||||||
|
print_error(f"CWD: {os.getcwd()}")
|
||||||
|
print_error(f"EXEC: {bat_file}")
|
||||||
|
print_error(f"Exec output:")
|
||||||
|
print_error(p.stdout)
|
||||||
|
raise RuntimeError(f"Error running bat file; {bat_file}")
|
||||||
|
|
||||||
|
args = args[1:]
|
||||||
|
|
||||||
|
try:
|
||||||
|
p = subprocess.run(
|
||||||
|
[wrapped_binary] + args,
|
||||||
|
stdout = subprocess.PIPE,
|
||||||
|
stderr = subprocess.STDOUT,
|
||||||
|
text=True)
|
||||||
|
if p.returncode != 0:
|
||||||
|
print_error("[Generated python wrapper] Error running command:")
|
||||||
|
print_error(f"CWD: {os.getcwd()}")
|
||||||
|
print_error(f"EXEC: {wrapped_binary}")
|
||||||
|
print_error(f"ARGS: {args}")
|
||||||
|
print_error(f"Exec output:")
|
||||||
|
print_error(p.stdout)
|
||||||
|
raise RuntimeError(f"Error running wrapped command; {wrapped_binary}")
|
||||||
|
except OSError as e:
|
||||||
|
print_error("[Generated python wrapper] Error running command:")
|
||||||
|
print_error(f"CWD: {os.getcwd()}")
|
||||||
|
print_error(f"EXEC: {wrapped_binary}")
|
||||||
|
print_error(f"ARGS: {args}")
|
||||||
|
raise
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
@echo off
|
@echo off
|
||||||
python.bat tools\gclient_hook.py
|
python3.bat tools\gclient_hook.py
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
python tools/gclient_hook.py
|
python3 tools/gclient_hook.py
|
||||||
|
|||||||
188
cef_paths.gypi
188
cef_paths.gypi
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
|
# Copyright (c) 2025 The Chromium Embedded Framework Authors. All rights
|
||||||
# reserved. Use of this source code is governed by a BSD-style license that
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
# can be found in the LICENSE file.
|
# can be found in the LICENSE file.
|
||||||
#
|
#
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
# by hand. See the translator.README.txt file in the tools directory for
|
# by hand. See the translator.README.txt file in the tools directory for
|
||||||
# more information.
|
# more information.
|
||||||
#
|
#
|
||||||
# $hash=61795daa573f965b6b94dea5b8220eeca37f62a0$
|
# $hash=f20d67335316b2bf388d5c02788c4024ad94f1e7$
|
||||||
#
|
#
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -22,10 +22,12 @@
|
|||||||
'include/cef_browser_process_handler.h',
|
'include/cef_browser_process_handler.h',
|
||||||
'include/cef_callback.h',
|
'include/cef_callback.h',
|
||||||
'include/cef_client.h',
|
'include/cef_client.h',
|
||||||
|
'include/cef_command_handler.h',
|
||||||
'include/cef_command_line.h',
|
'include/cef_command_line.h',
|
||||||
'include/cef_context_menu_handler.h',
|
'include/cef_context_menu_handler.h',
|
||||||
'include/cef_cookie.h',
|
'include/cef_cookie.h',
|
||||||
'include/cef_crash_util.h',
|
'include/cef_crash_util.h',
|
||||||
|
'include/cef_devtools_message_observer.h',
|
||||||
'include/cef_dialog_handler.h',
|
'include/cef_dialog_handler.h',
|
||||||
'include/cef_display_handler.h',
|
'include/cef_display_handler.h',
|
||||||
'include/cef_dom.h',
|
'include/cef_dom.h',
|
||||||
@@ -33,27 +35,31 @@
|
|||||||
'include/cef_download_item.h',
|
'include/cef_download_item.h',
|
||||||
'include/cef_drag_data.h',
|
'include/cef_drag_data.h',
|
||||||
'include/cef_drag_handler.h',
|
'include/cef_drag_handler.h',
|
||||||
'include/cef_extension.h',
|
|
||||||
'include/cef_extension_handler.h',
|
|
||||||
'include/cef_file_util.h',
|
'include/cef_file_util.h',
|
||||||
'include/cef_find_handler.h',
|
'include/cef_find_handler.h',
|
||||||
'include/cef_focus_handler.h',
|
'include/cef_focus_handler.h',
|
||||||
'include/cef_frame.h',
|
'include/cef_frame.h',
|
||||||
|
'include/cef_frame_handler.h',
|
||||||
|
'include/cef_i18n_util.h',
|
||||||
'include/cef_image.h',
|
'include/cef_image.h',
|
||||||
'include/cef_jsdialog_handler.h',
|
'include/cef_jsdialog_handler.h',
|
||||||
'include/cef_keyboard_handler.h',
|
'include/cef_keyboard_handler.h',
|
||||||
'include/cef_life_span_handler.h',
|
'include/cef_life_span_handler.h',
|
||||||
'include/cef_load_handler.h',
|
'include/cef_load_handler.h',
|
||||||
|
'include/cef_media_router.h',
|
||||||
'include/cef_menu_model.h',
|
'include/cef_menu_model.h',
|
||||||
'include/cef_menu_model_delegate.h',
|
'include/cef_menu_model_delegate.h',
|
||||||
'include/cef_navigation_entry.h',
|
'include/cef_navigation_entry.h',
|
||||||
'include/cef_origin_whitelist.h',
|
'include/cef_origin_whitelist.h',
|
||||||
'include/cef_parser.h',
|
'include/cef_parser.h',
|
||||||
'include/cef_path_util.h',
|
'include/cef_path_util.h',
|
||||||
|
'include/cef_permission_handler.h',
|
||||||
|
'include/cef_preference.h',
|
||||||
'include/cef_print_handler.h',
|
'include/cef_print_handler.h',
|
||||||
'include/cef_print_settings.h',
|
'include/cef_print_settings.h',
|
||||||
'include/cef_process_message.h',
|
'include/cef_process_message.h',
|
||||||
'include/cef_process_util.h',
|
'include/cef_process_util.h',
|
||||||
|
'include/cef_registration.h',
|
||||||
'include/cef_render_handler.h',
|
'include/cef_render_handler.h',
|
||||||
'include/cef_render_process_handler.h',
|
'include/cef_render_process_handler.h',
|
||||||
'include/cef_request.h',
|
'include/cef_request.h',
|
||||||
@@ -63,26 +69,31 @@
|
|||||||
'include/cef_resource_bundle.h',
|
'include/cef_resource_bundle.h',
|
||||||
'include/cef_resource_bundle_handler.h',
|
'include/cef_resource_bundle_handler.h',
|
||||||
'include/cef_resource_handler.h',
|
'include/cef_resource_handler.h',
|
||||||
|
'include/cef_resource_request_handler.h',
|
||||||
'include/cef_response.h',
|
'include/cef_response.h',
|
||||||
'include/cef_response_filter.h',
|
'include/cef_response_filter.h',
|
||||||
'include/cef_scheme.h',
|
'include/cef_scheme.h',
|
||||||
'include/cef_server.h',
|
'include/cef_server.h',
|
||||||
|
'include/cef_shared_memory_region.h',
|
||||||
|
'include/cef_shared_process_message_builder.h',
|
||||||
'include/cef_ssl_info.h',
|
'include/cef_ssl_info.h',
|
||||||
'include/cef_ssl_status.h',
|
'include/cef_ssl_status.h',
|
||||||
'include/cef_stream.h',
|
'include/cef_stream.h',
|
||||||
'include/cef_string_visitor.h',
|
'include/cef_string_visitor.h',
|
||||||
'include/cef_task.h',
|
'include/cef_task.h',
|
||||||
|
'include/cef_task_manager.h',
|
||||||
'include/cef_thread.h',
|
'include/cef_thread.h',
|
||||||
'include/cef_trace.h',
|
'include/cef_trace.h',
|
||||||
|
'include/cef_unresponsive_process_callback.h',
|
||||||
'include/cef_urlrequest.h',
|
'include/cef_urlrequest.h',
|
||||||
'include/cef_v8.h',
|
'include/cef_v8.h',
|
||||||
'include/cef_values.h',
|
'include/cef_values.h',
|
||||||
'include/cef_waitable_event.h',
|
'include/cef_waitable_event.h',
|
||||||
'include/cef_web_plugin.h',
|
|
||||||
'include/cef_x509_certificate.h',
|
'include/cef_x509_certificate.h',
|
||||||
'include/cef_xml_reader.h',
|
'include/cef_xml_reader.h',
|
||||||
'include/cef_zip_reader.h',
|
'include/cef_zip_reader.h',
|
||||||
'include/test/cef_test_helpers.h',
|
'include/test/cef_test_helpers.h',
|
||||||
|
'include/test/cef_test_server.h',
|
||||||
'include/test/cef_translator_test.h',
|
'include/test/cef_translator_test.h',
|
||||||
'include/views/cef_box_layout.h',
|
'include/views/cef_box_layout.h',
|
||||||
'include/views/cef_browser_view.h',
|
'include/views/cef_browser_view.h',
|
||||||
@@ -95,6 +106,7 @@
|
|||||||
'include/views/cef_layout.h',
|
'include/views/cef_layout.h',
|
||||||
'include/views/cef_menu_button.h',
|
'include/views/cef_menu_button.h',
|
||||||
'include/views/cef_menu_button_delegate.h',
|
'include/views/cef_menu_button_delegate.h',
|
||||||
|
'include/views/cef_overlay_controller.h',
|
||||||
'include/views/cef_panel.h',
|
'include/views/cef_panel.h',
|
||||||
'include/views/cef_panel_delegate.h',
|
'include/views/cef_panel_delegate.h',
|
||||||
'include/views/cef_scroll_view.h',
|
'include/views/cef_scroll_view.h',
|
||||||
@@ -114,10 +126,12 @@
|
|||||||
'include/capi/cef_browser_process_handler_capi.h',
|
'include/capi/cef_browser_process_handler_capi.h',
|
||||||
'include/capi/cef_callback_capi.h',
|
'include/capi/cef_callback_capi.h',
|
||||||
'include/capi/cef_client_capi.h',
|
'include/capi/cef_client_capi.h',
|
||||||
|
'include/capi/cef_command_handler_capi.h',
|
||||||
'include/capi/cef_command_line_capi.h',
|
'include/capi/cef_command_line_capi.h',
|
||||||
'include/capi/cef_context_menu_handler_capi.h',
|
'include/capi/cef_context_menu_handler_capi.h',
|
||||||
'include/capi/cef_cookie_capi.h',
|
'include/capi/cef_cookie_capi.h',
|
||||||
'include/capi/cef_crash_util_capi.h',
|
'include/capi/cef_crash_util_capi.h',
|
||||||
|
'include/capi/cef_devtools_message_observer_capi.h',
|
||||||
'include/capi/cef_dialog_handler_capi.h',
|
'include/capi/cef_dialog_handler_capi.h',
|
||||||
'include/capi/cef_display_handler_capi.h',
|
'include/capi/cef_display_handler_capi.h',
|
||||||
'include/capi/cef_dom_capi.h',
|
'include/capi/cef_dom_capi.h',
|
||||||
@@ -125,27 +139,31 @@
|
|||||||
'include/capi/cef_download_item_capi.h',
|
'include/capi/cef_download_item_capi.h',
|
||||||
'include/capi/cef_drag_data_capi.h',
|
'include/capi/cef_drag_data_capi.h',
|
||||||
'include/capi/cef_drag_handler_capi.h',
|
'include/capi/cef_drag_handler_capi.h',
|
||||||
'include/capi/cef_extension_capi.h',
|
|
||||||
'include/capi/cef_extension_handler_capi.h',
|
|
||||||
'include/capi/cef_file_util_capi.h',
|
'include/capi/cef_file_util_capi.h',
|
||||||
'include/capi/cef_find_handler_capi.h',
|
'include/capi/cef_find_handler_capi.h',
|
||||||
'include/capi/cef_focus_handler_capi.h',
|
'include/capi/cef_focus_handler_capi.h',
|
||||||
'include/capi/cef_frame_capi.h',
|
'include/capi/cef_frame_capi.h',
|
||||||
|
'include/capi/cef_frame_handler_capi.h',
|
||||||
|
'include/capi/cef_i18n_util_capi.h',
|
||||||
'include/capi/cef_image_capi.h',
|
'include/capi/cef_image_capi.h',
|
||||||
'include/capi/cef_jsdialog_handler_capi.h',
|
'include/capi/cef_jsdialog_handler_capi.h',
|
||||||
'include/capi/cef_keyboard_handler_capi.h',
|
'include/capi/cef_keyboard_handler_capi.h',
|
||||||
'include/capi/cef_life_span_handler_capi.h',
|
'include/capi/cef_life_span_handler_capi.h',
|
||||||
'include/capi/cef_load_handler_capi.h',
|
'include/capi/cef_load_handler_capi.h',
|
||||||
|
'include/capi/cef_media_router_capi.h',
|
||||||
'include/capi/cef_menu_model_capi.h',
|
'include/capi/cef_menu_model_capi.h',
|
||||||
'include/capi/cef_menu_model_delegate_capi.h',
|
'include/capi/cef_menu_model_delegate_capi.h',
|
||||||
'include/capi/cef_navigation_entry_capi.h',
|
'include/capi/cef_navigation_entry_capi.h',
|
||||||
'include/capi/cef_origin_whitelist_capi.h',
|
'include/capi/cef_origin_whitelist_capi.h',
|
||||||
'include/capi/cef_parser_capi.h',
|
'include/capi/cef_parser_capi.h',
|
||||||
'include/capi/cef_path_util_capi.h',
|
'include/capi/cef_path_util_capi.h',
|
||||||
|
'include/capi/cef_permission_handler_capi.h',
|
||||||
|
'include/capi/cef_preference_capi.h',
|
||||||
'include/capi/cef_print_handler_capi.h',
|
'include/capi/cef_print_handler_capi.h',
|
||||||
'include/capi/cef_print_settings_capi.h',
|
'include/capi/cef_print_settings_capi.h',
|
||||||
'include/capi/cef_process_message_capi.h',
|
'include/capi/cef_process_message_capi.h',
|
||||||
'include/capi/cef_process_util_capi.h',
|
'include/capi/cef_process_util_capi.h',
|
||||||
|
'include/capi/cef_registration_capi.h',
|
||||||
'include/capi/cef_render_handler_capi.h',
|
'include/capi/cef_render_handler_capi.h',
|
||||||
'include/capi/cef_render_process_handler_capi.h',
|
'include/capi/cef_render_process_handler_capi.h',
|
||||||
'include/capi/cef_request_capi.h',
|
'include/capi/cef_request_capi.h',
|
||||||
@@ -155,26 +173,31 @@
|
|||||||
'include/capi/cef_resource_bundle_capi.h',
|
'include/capi/cef_resource_bundle_capi.h',
|
||||||
'include/capi/cef_resource_bundle_handler_capi.h',
|
'include/capi/cef_resource_bundle_handler_capi.h',
|
||||||
'include/capi/cef_resource_handler_capi.h',
|
'include/capi/cef_resource_handler_capi.h',
|
||||||
|
'include/capi/cef_resource_request_handler_capi.h',
|
||||||
'include/capi/cef_response_capi.h',
|
'include/capi/cef_response_capi.h',
|
||||||
'include/capi/cef_response_filter_capi.h',
|
'include/capi/cef_response_filter_capi.h',
|
||||||
'include/capi/cef_scheme_capi.h',
|
'include/capi/cef_scheme_capi.h',
|
||||||
'include/capi/cef_server_capi.h',
|
'include/capi/cef_server_capi.h',
|
||||||
|
'include/capi/cef_shared_memory_region_capi.h',
|
||||||
|
'include/capi/cef_shared_process_message_builder_capi.h',
|
||||||
'include/capi/cef_ssl_info_capi.h',
|
'include/capi/cef_ssl_info_capi.h',
|
||||||
'include/capi/cef_ssl_status_capi.h',
|
'include/capi/cef_ssl_status_capi.h',
|
||||||
'include/capi/cef_stream_capi.h',
|
'include/capi/cef_stream_capi.h',
|
||||||
'include/capi/cef_string_visitor_capi.h',
|
'include/capi/cef_string_visitor_capi.h',
|
||||||
'include/capi/cef_task_capi.h',
|
'include/capi/cef_task_capi.h',
|
||||||
|
'include/capi/cef_task_manager_capi.h',
|
||||||
'include/capi/cef_thread_capi.h',
|
'include/capi/cef_thread_capi.h',
|
||||||
'include/capi/cef_trace_capi.h',
|
'include/capi/cef_trace_capi.h',
|
||||||
|
'include/capi/cef_unresponsive_process_callback_capi.h',
|
||||||
'include/capi/cef_urlrequest_capi.h',
|
'include/capi/cef_urlrequest_capi.h',
|
||||||
'include/capi/cef_v8_capi.h',
|
'include/capi/cef_v8_capi.h',
|
||||||
'include/capi/cef_values_capi.h',
|
'include/capi/cef_values_capi.h',
|
||||||
'include/capi/cef_waitable_event_capi.h',
|
'include/capi/cef_waitable_event_capi.h',
|
||||||
'include/capi/cef_web_plugin_capi.h',
|
|
||||||
'include/capi/cef_x509_certificate_capi.h',
|
'include/capi/cef_x509_certificate_capi.h',
|
||||||
'include/capi/cef_xml_reader_capi.h',
|
'include/capi/cef_xml_reader_capi.h',
|
||||||
'include/capi/cef_zip_reader_capi.h',
|
'include/capi/cef_zip_reader_capi.h',
|
||||||
'include/capi/test/cef_test_helpers_capi.h',
|
'include/capi/test/cef_test_helpers_capi.h',
|
||||||
|
'include/capi/test/cef_test_server_capi.h',
|
||||||
'include/capi/test/cef_translator_test_capi.h',
|
'include/capi/test/cef_translator_test_capi.h',
|
||||||
'include/capi/views/cef_box_layout_capi.h',
|
'include/capi/views/cef_box_layout_capi.h',
|
||||||
'include/capi/views/cef_browser_view_capi.h',
|
'include/capi/views/cef_browser_view_capi.h',
|
||||||
@@ -187,6 +210,7 @@
|
|||||||
'include/capi/views/cef_layout_capi.h',
|
'include/capi/views/cef_layout_capi.h',
|
||||||
'include/capi/views/cef_menu_button_capi.h',
|
'include/capi/views/cef_menu_button_capi.h',
|
||||||
'include/capi/views/cef_menu_button_delegate_capi.h',
|
'include/capi/views/cef_menu_button_delegate_capi.h',
|
||||||
|
'include/capi/views/cef_overlay_controller_capi.h',
|
||||||
'include/capi/views/cef_panel_capi.h',
|
'include/capi/views/cef_panel_capi.h',
|
||||||
'include/capi/views/cef_panel_delegate_capi.h',
|
'include/capi/views/cef_panel_delegate_capi.h',
|
||||||
'include/capi/views/cef_scroll_view_capi.h',
|
'include/capi/views/cef_scroll_view_capi.h',
|
||||||
@@ -230,6 +254,8 @@
|
|||||||
'libcef_dll/cpptoc/callback_cpptoc.h',
|
'libcef_dll/cpptoc/callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/client_ctocpp.cc',
|
'libcef_dll/ctocpp/client_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/client_ctocpp.h',
|
'libcef_dll/ctocpp/client_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/command_handler_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/command_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/command_line_cpptoc.cc',
|
'libcef_dll/cpptoc/command_line_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/command_line_cpptoc.h',
|
'libcef_dll/cpptoc/command_line_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/completion_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/completion_callback_ctocpp.cc',
|
||||||
@@ -238,6 +264,8 @@
|
|||||||
'libcef_dll/ctocpp/context_menu_handler_ctocpp.h',
|
'libcef_dll/ctocpp/context_menu_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/context_menu_params_cpptoc.cc',
|
'libcef_dll/cpptoc/context_menu_params_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/context_menu_params_cpptoc.h',
|
'libcef_dll/cpptoc/context_menu_params_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/cookie_access_filter_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/cookie_access_filter_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/cookie_manager_cpptoc.cc',
|
'libcef_dll/cpptoc/cookie_manager_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/cookie_manager_cpptoc.h',
|
'libcef_dll/cpptoc/cookie_manager_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc',
|
'libcef_dll/ctocpp/cookie_visitor_ctocpp.cc',
|
||||||
@@ -250,6 +278,8 @@
|
|||||||
'libcef_dll/ctocpp/domvisitor_ctocpp.h',
|
'libcef_dll/ctocpp/domvisitor_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h',
|
'libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/dev_tools_message_observer_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/dialog_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/dialog_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/dialog_handler_ctocpp.h',
|
'libcef_dll/ctocpp/dialog_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/dictionary_value_cpptoc.cc',
|
'libcef_dll/cpptoc/dictionary_value_cpptoc.cc',
|
||||||
@@ -272,10 +302,6 @@
|
|||||||
'libcef_dll/ctocpp/drag_handler_ctocpp.h',
|
'libcef_dll/ctocpp/drag_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.h',
|
'libcef_dll/ctocpp/end_tracing_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/extension_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/extension_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/extension_handler_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/extension_handler_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.h',
|
'libcef_dll/cpptoc/file_dialog_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/views/fill_layout_cpptoc.cc',
|
'libcef_dll/cpptoc/views/fill_layout_cpptoc.cc',
|
||||||
@@ -286,8 +312,8 @@
|
|||||||
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
|
'libcef_dll/ctocpp/focus_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/frame_cpptoc.cc',
|
'libcef_dll/cpptoc/frame_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/frame_cpptoc.h',
|
'libcef_dll/cpptoc/frame_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.cc',
|
'libcef_dll/ctocpp/frame_handler_ctocpp.cc',
|
||||||
'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h',
|
'libcef_dll/ctocpp/frame_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/image_cpptoc.cc',
|
'libcef_dll/cpptoc/image_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/image_cpptoc.h',
|
'libcef_dll/cpptoc/image_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc',
|
||||||
@@ -306,6 +332,22 @@
|
|||||||
'libcef_dll/cpptoc/list_value_cpptoc.h',
|
'libcef_dll/cpptoc/list_value_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/load_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/load_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/load_handler_ctocpp.h',
|
'libcef_dll/ctocpp/load_handler_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/media_access_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/media_access_callback_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/media_observer_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/media_observer_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/media_route_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/media_route_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/media_route_create_callback_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/media_router_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/media_router_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/media_sink_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/media_sink_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/media_sink_device_info_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/media_sink_device_info_callback_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/media_source_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/media_source_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/views/menu_button_cpptoc.cc',
|
'libcef_dll/cpptoc/views/menu_button_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/menu_button_cpptoc.h',
|
'libcef_dll/cpptoc/views/menu_button_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc',
|
'libcef_dll/ctocpp/views/menu_button_delegate_ctocpp.cc',
|
||||||
@@ -320,16 +362,26 @@
|
|||||||
'libcef_dll/cpptoc/navigation_entry_cpptoc.h',
|
'libcef_dll/cpptoc/navigation_entry_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.cc',
|
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.h',
|
'libcef_dll/ctocpp/navigation_entry_visitor_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/views/overlay_controller_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/views/overlay_controller_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/views/panel_cpptoc.cc',
|
'libcef_dll/cpptoc/views/panel_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/panel_cpptoc.h',
|
'libcef_dll/cpptoc/views/panel_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc',
|
'libcef_dll/ctocpp/views/panel_delegate_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/panel_delegate_ctocpp.h',
|
'libcef_dll/ctocpp/views/panel_delegate_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/pdf_print_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/pdf_print_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/pdf_print_callback_ctocpp.h',
|
'libcef_dll/ctocpp/pdf_print_callback_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/permission_handler_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/permission_handler_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/permission_prompt_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/permission_prompt_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/post_data_cpptoc.cc',
|
'libcef_dll/cpptoc/post_data_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/post_data_cpptoc.h',
|
'libcef_dll/cpptoc/post_data_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
|
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/post_data_element_cpptoc.h',
|
'libcef_dll/cpptoc/post_data_element_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/preference_manager_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/preference_manager_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/preference_registrar_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/preference_registrar_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.h',
|
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/print_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/print_handler_ctocpp.cc',
|
||||||
@@ -342,16 +394,14 @@
|
|||||||
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.cc',
|
'libcef_dll/cpptoc/registration_cpptoc.cc',
|
||||||
'libcef_dll/ctocpp/register_cdm_callback_ctocpp.h',
|
'libcef_dll/cpptoc/registration_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/render_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/render_handler_ctocpp.h',
|
'libcef_dll/ctocpp/render_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/render_process_handler_ctocpp.h',
|
'libcef_dll/ctocpp/render_process_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/request_cpptoc.cc',
|
'libcef_dll/cpptoc/request_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/request_cpptoc.h',
|
'libcef_dll/cpptoc/request_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/request_callback_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/request_callback_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/request_context_cpptoc.cc',
|
'libcef_dll/cpptoc/request_context_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/request_context_cpptoc.h',
|
'libcef_dll/cpptoc/request_context_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/request_context_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/request_context_handler_ctocpp.cc',
|
||||||
@@ -366,6 +416,12 @@
|
|||||||
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h',
|
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/resource_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/resource_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/resource_handler_ctocpp.h',
|
'libcef_dll/ctocpp/resource_handler_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/resource_read_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/resource_read_callback_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/resource_request_handler_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/resource_request_handler_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/resource_skip_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/resource_skip_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/response_cpptoc.cc',
|
'libcef_dll/cpptoc/response_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/response_cpptoc.h',
|
'libcef_dll/cpptoc/response_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/response_filter_ctocpp.cc',
|
'libcef_dll/ctocpp/response_filter_ctocpp.cc',
|
||||||
@@ -374,6 +430,8 @@
|
|||||||
'libcef_dll/cpptoc/run_context_menu_callback_cpptoc.h',
|
'libcef_dll/cpptoc/run_context_menu_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h',
|
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/run_quick_menu_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/run_quick_menu_callback_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/sslinfo_cpptoc.cc',
|
'libcef_dll/cpptoc/sslinfo_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/sslinfo_cpptoc.h',
|
'libcef_dll/cpptoc/sslinfo_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/sslstatus_cpptoc.cc',
|
'libcef_dll/cpptoc/sslstatus_cpptoc.cc',
|
||||||
@@ -392,6 +450,10 @@
|
|||||||
'libcef_dll/ctocpp/server_handler_ctocpp.h',
|
'libcef_dll/ctocpp/server_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.h',
|
'libcef_dll/ctocpp/set_cookie_callback_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/shared_memory_region_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/shared_memory_region_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/shared_process_message_builder_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/shared_process_message_builder_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/stream_reader_cpptoc.cc',
|
'libcef_dll/cpptoc/stream_reader_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/stream_reader_cpptoc.h',
|
'libcef_dll/cpptoc/stream_reader_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/stream_writer_cpptoc.cc',
|
'libcef_dll/cpptoc/stream_writer_cpptoc.cc',
|
||||||
@@ -400,8 +462,16 @@
|
|||||||
'libcef_dll/ctocpp/string_visitor_ctocpp.h',
|
'libcef_dll/ctocpp/string_visitor_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/task_ctocpp.cc',
|
'libcef_dll/ctocpp/task_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/task_ctocpp.h',
|
'libcef_dll/ctocpp/task_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/task_manager_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/task_manager_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/task_runner_cpptoc.cc',
|
'libcef_dll/cpptoc/task_runner_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/task_runner_cpptoc.h',
|
'libcef_dll/cpptoc/task_runner_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/test/test_server_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/test/test_server_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/test/test_server_connection_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/test/test_server_connection_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/test/test_server_handler_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/test/test_server_handler_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/textfield_cpptoc.cc',
|
'libcef_dll/cpptoc/views/textfield_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/textfield_cpptoc.h',
|
'libcef_dll/cpptoc/views/textfield_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc',
|
'libcef_dll/ctocpp/views/textfield_delegate_ctocpp.cc',
|
||||||
@@ -434,6 +504,8 @@
|
|||||||
'libcef_dll/cpptoc/urlrequest_cpptoc.h',
|
'libcef_dll/cpptoc/urlrequest_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/urlrequest_client_ctocpp.cc',
|
'libcef_dll/ctocpp/urlrequest_client_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/urlrequest_client_ctocpp.h',
|
'libcef_dll/ctocpp/urlrequest_client_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/v8accessor_ctocpp.cc',
|
'libcef_dll/ctocpp/v8accessor_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/v8accessor_ctocpp.h',
|
'libcef_dll/ctocpp/v8accessor_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/v8array_buffer_release_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/v8array_buffer_release_callback_ctocpp.cc',
|
||||||
@@ -460,12 +532,6 @@
|
|||||||
'libcef_dll/ctocpp/views/view_delegate_ctocpp.h',
|
'libcef_dll/ctocpp/views/view_delegate_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/waitable_event_cpptoc.cc',
|
'libcef_dll/cpptoc/waitable_event_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/waitable_event_cpptoc.h',
|
'libcef_dll/cpptoc/waitable_event_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/web_plugin_info_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/web_plugin_info_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/web_plugin_info_visitor_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/web_plugin_unstable_callback_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/views/window_cpptoc.cc',
|
'libcef_dll/cpptoc/views/window_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/window_cpptoc.h',
|
'libcef_dll/cpptoc/views/window_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/window_delegate_ctocpp.cc',
|
'libcef_dll/ctocpp/views/window_delegate_ctocpp.cc',
|
||||||
@@ -514,6 +580,8 @@
|
|||||||
'libcef_dll/ctocpp/callback_ctocpp.h',
|
'libcef_dll/ctocpp/callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/client_cpptoc.cc',
|
'libcef_dll/cpptoc/client_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/client_cpptoc.h',
|
'libcef_dll/cpptoc/client_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/command_handler_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/command_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/command_line_ctocpp.cc',
|
'libcef_dll/ctocpp/command_line_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/command_line_ctocpp.h',
|
'libcef_dll/ctocpp/command_line_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/completion_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/completion_callback_cpptoc.cc',
|
||||||
@@ -522,6 +590,8 @@
|
|||||||
'libcef_dll/cpptoc/context_menu_handler_cpptoc.h',
|
'libcef_dll/cpptoc/context_menu_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/context_menu_params_ctocpp.cc',
|
'libcef_dll/ctocpp/context_menu_params_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/context_menu_params_ctocpp.h',
|
'libcef_dll/ctocpp/context_menu_params_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/cookie_access_filter_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/cookie_access_filter_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/cookie_manager_ctocpp.cc',
|
'libcef_dll/ctocpp/cookie_manager_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/cookie_manager_ctocpp.h',
|
'libcef_dll/ctocpp/cookie_manager_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc',
|
'libcef_dll/cpptoc/cookie_visitor_cpptoc.cc',
|
||||||
@@ -534,6 +604,8 @@
|
|||||||
'libcef_dll/cpptoc/domvisitor_cpptoc.h',
|
'libcef_dll/cpptoc/domvisitor_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h',
|
'libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/dev_tools_message_observer_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/dev_tools_message_observer_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/dialog_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/dialog_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/dialog_handler_cpptoc.h',
|
'libcef_dll/cpptoc/dialog_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/dictionary_value_ctocpp.cc',
|
'libcef_dll/ctocpp/dictionary_value_ctocpp.cc',
|
||||||
@@ -556,10 +628,6 @@
|
|||||||
'libcef_dll/cpptoc/drag_handler_cpptoc.h',
|
'libcef_dll/cpptoc/drag_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.h',
|
'libcef_dll/cpptoc/end_tracing_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/extension_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/extension_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/extension_handler_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/extension_handler_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.h',
|
'libcef_dll/ctocpp/file_dialog_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/views/fill_layout_ctocpp.cc',
|
'libcef_dll/ctocpp/views/fill_layout_ctocpp.cc',
|
||||||
@@ -570,8 +638,8 @@
|
|||||||
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
|
'libcef_dll/cpptoc/focus_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/frame_ctocpp.cc',
|
'libcef_dll/ctocpp/frame_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/frame_ctocpp.h',
|
'libcef_dll/ctocpp/frame_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.cc',
|
'libcef_dll/cpptoc/frame_handler_cpptoc.cc',
|
||||||
'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h',
|
'libcef_dll/cpptoc/frame_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/image_ctocpp.cc',
|
'libcef_dll/ctocpp/image_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/image_ctocpp.h',
|
'libcef_dll/ctocpp/image_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc',
|
||||||
@@ -590,6 +658,22 @@
|
|||||||
'libcef_dll/ctocpp/list_value_ctocpp.h',
|
'libcef_dll/ctocpp/list_value_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/load_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/load_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/load_handler_cpptoc.h',
|
'libcef_dll/cpptoc/load_handler_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/media_access_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/media_access_callback_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/media_observer_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/media_observer_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/media_route_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/media_route_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/media_route_create_callback_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/media_router_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/media_router_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/media_sink_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/media_sink_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/media_sink_device_info_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/media_sink_device_info_callback_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/media_source_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/media_source_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/views/menu_button_ctocpp.cc',
|
'libcef_dll/ctocpp/views/menu_button_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/menu_button_ctocpp.h',
|
'libcef_dll/ctocpp/views/menu_button_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc',
|
'libcef_dll/cpptoc/views/menu_button_delegate_cpptoc.cc',
|
||||||
@@ -604,16 +688,26 @@
|
|||||||
'libcef_dll/ctocpp/navigation_entry_ctocpp.h',
|
'libcef_dll/ctocpp/navigation_entry_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.cc',
|
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.h',
|
'libcef_dll/cpptoc/navigation_entry_visitor_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/views/overlay_controller_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/views/overlay_controller_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/views/panel_ctocpp.cc',
|
'libcef_dll/ctocpp/views/panel_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/panel_ctocpp.h',
|
'libcef_dll/ctocpp/views/panel_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc',
|
'libcef_dll/cpptoc/views/panel_delegate_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/views/panel_delegate_cpptoc.h',
|
'libcef_dll/cpptoc/views/panel_delegate_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/pdf_print_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/pdf_print_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/pdf_print_callback_cpptoc.h',
|
'libcef_dll/cpptoc/pdf_print_callback_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/permission_handler_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/permission_handler_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/permission_prompt_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/permission_prompt_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/post_data_ctocpp.cc',
|
'libcef_dll/ctocpp/post_data_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/post_data_ctocpp.h',
|
'libcef_dll/ctocpp/post_data_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
|
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/post_data_element_ctocpp.h',
|
'libcef_dll/ctocpp/post_data_element_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/preference_manager_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/preference_manager_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/preference_registrar_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/preference_registrar_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.cc',
|
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.h',
|
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/print_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/print_handler_cpptoc.cc',
|
||||||
@@ -626,16 +720,14 @@
|
|||||||
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.cc',
|
'libcef_dll/ctocpp/registration_ctocpp.cc',
|
||||||
'libcef_dll/cpptoc/register_cdm_callback_cpptoc.h',
|
'libcef_dll/ctocpp/registration_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/render_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/render_handler_cpptoc.h',
|
'libcef_dll/cpptoc/render_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/render_process_handler_cpptoc.h',
|
'libcef_dll/cpptoc/render_process_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/request_ctocpp.cc',
|
'libcef_dll/ctocpp/request_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/request_ctocpp.h',
|
'libcef_dll/ctocpp/request_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/request_callback_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/request_callback_ctocpp.h',
|
|
||||||
'libcef_dll/ctocpp/request_context_ctocpp.cc',
|
'libcef_dll/ctocpp/request_context_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/request_context_ctocpp.h',
|
'libcef_dll/ctocpp/request_context_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/request_context_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/request_context_handler_cpptoc.cc',
|
||||||
@@ -650,6 +742,12 @@
|
|||||||
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h',
|
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/resource_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/resource_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/resource_handler_cpptoc.h',
|
'libcef_dll/cpptoc/resource_handler_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/resource_read_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/resource_read_callback_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/resource_request_handler_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/resource_request_handler_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/resource_skip_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/resource_skip_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/response_ctocpp.cc',
|
'libcef_dll/ctocpp/response_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/response_ctocpp.h',
|
'libcef_dll/ctocpp/response_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/response_filter_cpptoc.cc',
|
'libcef_dll/cpptoc/response_filter_cpptoc.cc',
|
||||||
@@ -658,6 +756,8 @@
|
|||||||
'libcef_dll/ctocpp/run_context_menu_callback_ctocpp.h',
|
'libcef_dll/ctocpp/run_context_menu_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h',
|
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/run_quick_menu_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/run_quick_menu_callback_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/sslinfo_ctocpp.cc',
|
'libcef_dll/ctocpp/sslinfo_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/sslinfo_ctocpp.h',
|
'libcef_dll/ctocpp/sslinfo_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/sslstatus_ctocpp.cc',
|
'libcef_dll/ctocpp/sslstatus_ctocpp.cc',
|
||||||
@@ -676,6 +776,10 @@
|
|||||||
'libcef_dll/cpptoc/server_handler_cpptoc.h',
|
'libcef_dll/cpptoc/server_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.h',
|
'libcef_dll/cpptoc/set_cookie_callback_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/shared_memory_region_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/shared_memory_region_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/shared_process_message_builder_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/shared_process_message_builder_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/stream_reader_ctocpp.cc',
|
'libcef_dll/ctocpp/stream_reader_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/stream_reader_ctocpp.h',
|
'libcef_dll/ctocpp/stream_reader_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/stream_writer_ctocpp.cc',
|
'libcef_dll/ctocpp/stream_writer_ctocpp.cc',
|
||||||
@@ -684,8 +788,16 @@
|
|||||||
'libcef_dll/cpptoc/string_visitor_cpptoc.h',
|
'libcef_dll/cpptoc/string_visitor_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/task_cpptoc.cc',
|
'libcef_dll/cpptoc/task_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/task_cpptoc.h',
|
'libcef_dll/cpptoc/task_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/task_manager_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/task_manager_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/task_runner_ctocpp.cc',
|
'libcef_dll/ctocpp/task_runner_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/task_runner_ctocpp.h',
|
'libcef_dll/ctocpp/task_runner_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/test/test_server_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/test/test_server_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/test/test_server_connection_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/test/test_server_connection_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/test/test_server_handler_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/test/test_server_handler_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/views/textfield_ctocpp.cc',
|
'libcef_dll/ctocpp/views/textfield_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/textfield_ctocpp.h',
|
'libcef_dll/ctocpp/views/textfield_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc',
|
'libcef_dll/cpptoc/views/textfield_delegate_cpptoc.cc',
|
||||||
@@ -718,6 +830,8 @@
|
|||||||
'libcef_dll/ctocpp/urlrequest_ctocpp.h',
|
'libcef_dll/ctocpp/urlrequest_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/urlrequest_client_cpptoc.cc',
|
'libcef_dll/cpptoc/urlrequest_client_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/urlrequest_client_cpptoc.h',
|
'libcef_dll/cpptoc/urlrequest_client_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/v8accessor_cpptoc.cc',
|
'libcef_dll/cpptoc/v8accessor_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/v8accessor_cpptoc.h',
|
'libcef_dll/cpptoc/v8accessor_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/v8array_buffer_release_callback_cpptoc.cc',
|
'libcef_dll/cpptoc/v8array_buffer_release_callback_cpptoc.cc',
|
||||||
@@ -744,12 +858,6 @@
|
|||||||
'libcef_dll/cpptoc/views/view_delegate_cpptoc.h',
|
'libcef_dll/cpptoc/views/view_delegate_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/waitable_event_ctocpp.cc',
|
'libcef_dll/ctocpp/waitable_event_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/waitable_event_ctocpp.h',
|
'libcef_dll/ctocpp/waitable_event_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/web_plugin_info_ctocpp.cc',
|
|
||||||
'libcef_dll/ctocpp/web_plugin_info_ctocpp.h',
|
|
||||||
'libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/web_plugin_info_visitor_cpptoc.h',
|
|
||||||
'libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.cc',
|
|
||||||
'libcef_dll/cpptoc/web_plugin_unstable_callback_cpptoc.h',
|
|
||||||
'libcef_dll/ctocpp/views/window_ctocpp.cc',
|
'libcef_dll/ctocpp/views/window_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/views/window_ctocpp.h',
|
'libcef_dll/ctocpp/views/window_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/views/window_delegate_cpptoc.cc',
|
'libcef_dll/cpptoc/views/window_delegate_cpptoc.cc',
|
||||||
|
|||||||
288
cef_paths2.gypi
288
cef_paths2.gypi
@@ -5,51 +5,61 @@
|
|||||||
{
|
{
|
||||||
'variables': {
|
'variables': {
|
||||||
'includes_common': [
|
'includes_common': [
|
||||||
|
'include/base/cef_atomic_flag.h',
|
||||||
'include/base/cef_atomic_ref_count.h',
|
'include/base/cef_atomic_ref_count.h',
|
||||||
'include/base/cef_atomicops.h',
|
'include/base/cef_auto_reset.h',
|
||||||
'include/base/cef_basictypes.h',
|
|
||||||
'include/base/cef_bind.h',
|
'include/base/cef_bind.h',
|
||||||
'include/base/cef_bind_helpers.h',
|
|
||||||
'include/base/cef_build.h',
|
'include/base/cef_build.h',
|
||||||
'include/base/cef_callback.h',
|
'include/base/cef_callback.h',
|
||||||
'include/base/cef_callback_forward.h',
|
'include/base/cef_callback_forward.h',
|
||||||
'include/base/cef_callback_helpers.h',
|
'include/base/cef_callback_helpers.h',
|
||||||
'include/base/cef_callback_list.h',
|
'include/base/cef_callback_list.h',
|
||||||
'include/base/cef_cancelable_callback.h',
|
'include/base/cef_cancelable_callback.h',
|
||||||
|
'include/base/cef_compiler_specific.h',
|
||||||
|
'include/base/cef_dump_without_crashing.h',
|
||||||
'include/base/cef_lock.h',
|
'include/base/cef_lock.h',
|
||||||
'include/base/cef_logging.h',
|
'include/base/cef_logging.h',
|
||||||
'include/base/cef_macros.h',
|
'include/base/cef_macros.h',
|
||||||
'include/base/cef_move.h',
|
|
||||||
'include/base/cef_platform_thread.h',
|
'include/base/cef_platform_thread.h',
|
||||||
'include/base/cef_ref_counted.h',
|
'include/base/cef_ref_counted.h',
|
||||||
'include/base/cef_scoped_ptr.h',
|
'include/base/cef_scoped_refptr.h',
|
||||||
'include/base/cef_string16.h',
|
|
||||||
'include/base/cef_template_util.h',
|
|
||||||
'include/base/cef_thread_checker.h',
|
'include/base/cef_thread_checker.h',
|
||||||
'include/base/cef_trace_event.h',
|
'include/base/cef_trace_event.h',
|
||||||
'include/base/cef_tuple.h',
|
'include/base/cef_tuple.h',
|
||||||
'include/base/cef_weak_ptr.h',
|
'include/base/cef_weak_ptr.h',
|
||||||
'include/base/internal/cef_bind_internal.h',
|
'include/base/internal/cef_bind_internal.h',
|
||||||
'include/base/internal/cef_callback_internal.h',
|
'include/base/internal/cef_callback_internal.h',
|
||||||
|
'include/base/internal/cef_color_id_macros.inc',
|
||||||
'include/base/internal/cef_lock_impl.h',
|
'include/base/internal/cef_lock_impl.h',
|
||||||
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
|
'include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h',
|
||||||
|
'include/base/internal/cef_scoped_policy.h',
|
||||||
'include/base/internal/cef_thread_checker_impl.h',
|
'include/base/internal/cef_thread_checker_impl.h',
|
||||||
|
'include/cef_api_hash.h',
|
||||||
'include/cef_base.h',
|
'include/cef_base.h',
|
||||||
'include/cef_version.h',
|
'include/cef_version.h',
|
||||||
'include/internal/cef_export.h',
|
'include/internal/cef_export.h',
|
||||||
'include/internal/cef_logging_internal.h',
|
|
||||||
'include/internal/cef_ptr.h',
|
'include/internal/cef_ptr.h',
|
||||||
|
'include/internal/cef_string_wrappers.h',
|
||||||
|
'include/internal/cef_time_wrappers.h',
|
||||||
|
'include/internal/cef_types_wrappers.h',
|
||||||
|
],
|
||||||
|
'includes_common_capi': [
|
||||||
|
'include/internal/cef_dump_without_crashing_internal.h',
|
||||||
|
'include/internal/cef_logging_internal.h',
|
||||||
'include/internal/cef_string.h',
|
'include/internal/cef_string.h',
|
||||||
'include/internal/cef_string_list.h',
|
'include/internal/cef_string_list.h',
|
||||||
'include/internal/cef_string_map.h',
|
'include/internal/cef_string_map.h',
|
||||||
'include/internal/cef_string_multimap.h',
|
'include/internal/cef_string_multimap.h',
|
||||||
'include/internal/cef_string_types.h',
|
'include/internal/cef_string_types.h',
|
||||||
'include/internal/cef_string_wrappers.h',
|
|
||||||
'include/internal/cef_thread_internal.h',
|
'include/internal/cef_thread_internal.h',
|
||||||
'include/internal/cef_time.h',
|
'include/internal/cef_time.h',
|
||||||
'include/internal/cef_trace_event_internal.h',
|
'include/internal/cef_trace_event_internal.h',
|
||||||
'include/internal/cef_types.h',
|
'include/internal/cef_types.h',
|
||||||
'include/internal/cef_types_wrappers.h',
|
'include/internal/cef_types_color.h',
|
||||||
|
'include/internal/cef_types_content_settings.h',
|
||||||
|
'include/internal/cef_types_geometry.h',
|
||||||
|
'include/internal/cef_types_osr.h',
|
||||||
|
'include/internal/cef_types_runtime.h',
|
||||||
],
|
],
|
||||||
'includes_capi': [
|
'includes_capi': [
|
||||||
'include/capi/cef_base_capi.h',
|
'include/capi/cef_base_capi.h',
|
||||||
@@ -69,25 +79,27 @@
|
|||||||
'include/wrapper/cef_library_loader.h',
|
'include/wrapper/cef_library_loader.h',
|
||||||
],
|
],
|
||||||
'includes_win': [
|
'includes_win': [
|
||||||
'include/base/internal/cef_atomicops_x86_msvc.h',
|
|
||||||
'include/base/internal/cef_bind_internal_win.h',
|
|
||||||
'include/cef_sandbox_win.h',
|
'include/cef_sandbox_win.h',
|
||||||
'include/internal/cef_types_win.h',
|
|
||||||
'include/internal/cef_win.h',
|
'include/internal/cef_win.h',
|
||||||
],
|
],
|
||||||
|
'includes_win_capi': [
|
||||||
|
'include/internal/cef_app_win.h',
|
||||||
|
'include/internal/cef_types_win.h',
|
||||||
|
],
|
||||||
'includes_mac': [
|
'includes_mac': [
|
||||||
'include/base/internal/cef_atomicops_atomicword_compat.h',
|
'include/base/cef_scoped_typeref_mac.h',
|
||||||
'include/base/internal/cef_atomicops_mac.h',
|
'include/base/internal/cef_scoped_block_mac.h',
|
||||||
'include/cef_application_mac.h',
|
'include/cef_application_mac.h',
|
||||||
'include/cef_sandbox_mac.h',
|
'include/cef_sandbox_mac.h',
|
||||||
'include/internal/cef_mac.h',
|
'include/internal/cef_mac.h',
|
||||||
|
],
|
||||||
|
'includes_mac_capi': [
|
||||||
'include/internal/cef_types_mac.h',
|
'include/internal/cef_types_mac.h',
|
||||||
],
|
],
|
||||||
'includes_linux': [
|
'includes_linux': [
|
||||||
'include/base/internal/cef_atomicops_atomicword_compat.h',
|
|
||||||
'include/base/internal/cef_atomicops_arm_gcc.h',
|
|
||||||
'include/base/internal/cef_atomicops_x86_gcc.h',
|
|
||||||
'include/internal/cef_linux.h',
|
'include/internal/cef_linux.h',
|
||||||
|
],
|
||||||
|
'includes_linux_capi': [
|
||||||
'include/internal/cef_types_linux.h',
|
'include/internal/cef_types_linux.h',
|
||||||
],
|
],
|
||||||
'libcef_sources_common': [
|
'libcef_sources_common': [
|
||||||
@@ -105,20 +117,20 @@
|
|||||||
'libcef_dll/resource.h',
|
'libcef_dll/resource.h',
|
||||||
'libcef_dll/shutdown_checker.cc',
|
'libcef_dll/shutdown_checker.cc',
|
||||||
'libcef_dll/shutdown_checker.h',
|
'libcef_dll/shutdown_checker.h',
|
||||||
|
'libcef_dll/template_util.h',
|
||||||
'libcef_dll/transfer_util.cc',
|
'libcef_dll/transfer_util.cc',
|
||||||
'libcef_dll/transfer_util.h',
|
'libcef_dll/transfer_util.h',
|
||||||
'libcef_dll/wrapper_types.h',
|
'libcef_dll/wrapper_types.h',
|
||||||
],
|
],
|
||||||
'libcef_dll_wrapper_sources_base': [
|
'libcef_dll_wrapper_sources_base': [
|
||||||
'libcef_dll/base/cef_atomicops_x86_gcc.cc',
|
'libcef_dll/base/cef_atomic_flag.cc',
|
||||||
'libcef_dll/base/cef_bind_helpers.cc',
|
|
||||||
'libcef_dll/base/cef_callback_helpers.cc',
|
'libcef_dll/base/cef_callback_helpers.cc',
|
||||||
'libcef_dll/base/cef_callback_internal.cc',
|
'libcef_dll/base/cef_callback_internal.cc',
|
||||||
|
'libcef_dll/base/cef_dump_without_crashing.cc',
|
||||||
'libcef_dll/base/cef_lock.cc',
|
'libcef_dll/base/cef_lock.cc',
|
||||||
'libcef_dll/base/cef_lock_impl.cc',
|
'libcef_dll/base/cef_lock_impl.cc',
|
||||||
'libcef_dll/base/cef_logging.cc',
|
'libcef_dll/base/cef_logging.cc',
|
||||||
'libcef_dll/base/cef_ref_counted.cc',
|
'libcef_dll/base/cef_ref_counted.cc',
|
||||||
'libcef_dll/base/cef_string16.cc',
|
|
||||||
'libcef_dll/base/cef_thread_checker_impl.cc',
|
'libcef_dll/base/cef_thread_checker_impl.cc',
|
||||||
'libcef_dll/base/cef_weak_ptr.cc',
|
'libcef_dll/base/cef_weak_ptr.cc',
|
||||||
],
|
],
|
||||||
@@ -131,9 +143,9 @@
|
|||||||
'libcef_dll/cpptoc/cpptoc_scoped.h',
|
'libcef_dll/cpptoc/cpptoc_scoped.h',
|
||||||
'libcef_dll/ctocpp/ctocpp_ref_counted.h',
|
'libcef_dll/ctocpp/ctocpp_ref_counted.h',
|
||||||
'libcef_dll/ctocpp/ctocpp_scoped.h',
|
'libcef_dll/ctocpp/ctocpp_scoped.h',
|
||||||
'libcef_dll/ptr_util.h',
|
|
||||||
'libcef_dll/shutdown_checker.cc',
|
'libcef_dll/shutdown_checker.cc',
|
||||||
'libcef_dll/shutdown_checker.h',
|
'libcef_dll/shutdown_checker.h',
|
||||||
|
'libcef_dll/template_util.h',
|
||||||
'libcef_dll/transfer_util.cc',
|
'libcef_dll/transfer_util.cc',
|
||||||
'libcef_dll/transfer_util.h',
|
'libcef_dll/transfer_util.h',
|
||||||
'libcef_dll/wrapper_types.h',
|
'libcef_dll/wrapper_types.h',
|
||||||
@@ -141,6 +153,8 @@
|
|||||||
'libcef_dll/wrapper/cef_byte_read_handler.cc',
|
'libcef_dll/wrapper/cef_byte_read_handler.cc',
|
||||||
'libcef_dll/wrapper/cef_closure_task.cc',
|
'libcef_dll/wrapper/cef_closure_task.cc',
|
||||||
'libcef_dll/wrapper/cef_message_router.cc',
|
'libcef_dll/wrapper/cef_message_router.cc',
|
||||||
|
'libcef_dll/wrapper/cef_message_router_utils.cc',
|
||||||
|
'libcef_dll/wrapper/cef_message_router_utils.h',
|
||||||
'libcef_dll/wrapper/cef_resource_manager.cc',
|
'libcef_dll/wrapper/cef_resource_manager.cc',
|
||||||
'libcef_dll/wrapper/cef_scoped_temp_dir.cc',
|
'libcef_dll/wrapper/cef_scoped_temp_dir.cc',
|
||||||
'libcef_dll/wrapper/cef_stream_resource_handler.cc',
|
'libcef_dll/wrapper/cef_stream_resource_handler.cc',
|
||||||
@@ -156,8 +170,6 @@
|
|||||||
'shared_sources_browser': [
|
'shared_sources_browser': [
|
||||||
'tests/shared/browser/client_app_browser.cc',
|
'tests/shared/browser/client_app_browser.cc',
|
||||||
'tests/shared/browser/client_app_browser.h',
|
'tests/shared/browser/client_app_browser.h',
|
||||||
'tests/shared/browser/extension_util.cc',
|
|
||||||
'tests/shared/browser/extension_util.h',
|
|
||||||
'tests/shared/browser/file_util.cc',
|
'tests/shared/browser/file_util.cc',
|
||||||
'tests/shared/browser/file_util.h',
|
'tests/shared/browser/file_util.h',
|
||||||
'tests/shared/browser/geometry_util.cc',
|
'tests/shared/browser/geometry_util.cc',
|
||||||
@@ -171,12 +183,16 @@
|
|||||||
'tests/shared/browser/resource_util.h',
|
'tests/shared/browser/resource_util.h',
|
||||||
],
|
],
|
||||||
'shared_sources_common': [
|
'shared_sources_common': [
|
||||||
|
'tests/shared/common/binary_value_utils.cc',
|
||||||
|
'tests/shared/common/binary_value_utils.h',
|
||||||
'tests/shared/common/client_app.cc',
|
'tests/shared/common/client_app.cc',
|
||||||
'tests/shared/common/client_app.h',
|
'tests/shared/common/client_app.h',
|
||||||
'tests/shared/common/client_app_other.cc',
|
'tests/shared/common/client_app_other.cc',
|
||||||
'tests/shared/common/client_app_other.h',
|
'tests/shared/common/client_app_other.h',
|
||||||
'tests/shared/common/client_switches.cc',
|
'tests/shared/common/client_switches.cc',
|
||||||
'tests/shared/common/client_switches.h',
|
'tests/shared/common/client_switches.h',
|
||||||
|
'tests/shared/common/string_util.cc',
|
||||||
|
'tests/shared/common/string_util.h',
|
||||||
],
|
],
|
||||||
'shared_sources_renderer': [
|
'shared_sources_renderer': [
|
||||||
'tests/shared/renderer/client_app_renderer.cc',
|
'tests/shared/renderer/client_app_renderer.cc',
|
||||||
@@ -208,6 +224,10 @@
|
|||||||
'tests/shared/browser/util_win.h',
|
'tests/shared/browser/util_win.h',
|
||||||
],
|
],
|
||||||
'cefclient_sources_browser': [
|
'cefclient_sources_browser': [
|
||||||
|
'tests/cefclient/browser/base_client_handler.cc',
|
||||||
|
'tests/cefclient/browser/base_client_handler.h',
|
||||||
|
'tests/cefclient/browser/binary_transfer_test.cc',
|
||||||
|
'tests/cefclient/browser/binary_transfer_test.h',
|
||||||
'tests/cefclient/browser/binding_test.cc',
|
'tests/cefclient/browser/binding_test.cc',
|
||||||
'tests/cefclient/browser/binding_test.h',
|
'tests/cefclient/browser/binding_test.h',
|
||||||
'tests/cefclient/browser/browser_window.cc',
|
'tests/cefclient/browser/browser_window.cc',
|
||||||
@@ -223,17 +243,23 @@
|
|||||||
'tests/cefclient/browser/client_handler_osr.h',
|
'tests/cefclient/browser/client_handler_osr.h',
|
||||||
'tests/cefclient/browser/client_handler_std.cc',
|
'tests/cefclient/browser/client_handler_std.cc',
|
||||||
'tests/cefclient/browser/client_handler_std.h',
|
'tests/cefclient/browser/client_handler_std.h',
|
||||||
|
'tests/cefclient/browser/client_prefs.cc',
|
||||||
|
'tests/cefclient/browser/client_prefs.h',
|
||||||
'tests/cefclient/browser/client_types.h',
|
'tests/cefclient/browser/client_types.h',
|
||||||
|
'tests/cefclient/browser/default_client_handler.cc',
|
||||||
|
'tests/cefclient/browser/default_client_handler.h',
|
||||||
'tests/cefclient/browser/dialog_test.cc',
|
'tests/cefclient/browser/dialog_test.cc',
|
||||||
'tests/cefclient/browser/dialog_test.h',
|
'tests/cefclient/browser/dialog_test.h',
|
||||||
'tests/cefclient/browser/drm_test.cc',
|
'tests/cefclient/browser/hang_test.cc',
|
||||||
'tests/cefclient/browser/drm_test.h',
|
'tests/cefclient/browser/hang_test.h',
|
||||||
'tests/cefclient/browser/image_cache.cc',
|
'tests/cefclient/browser/image_cache.cc',
|
||||||
'tests/cefclient/browser/image_cache.h',
|
'tests/cefclient/browser/image_cache.h',
|
||||||
'tests/cefclient/browser/main_context.cc',
|
'tests/cefclient/browser/main_context.cc',
|
||||||
'tests/cefclient/browser/main_context.h',
|
'tests/cefclient/browser/main_context.h',
|
||||||
'tests/cefclient/browser/main_context_impl.cc',
|
'tests/cefclient/browser/main_context_impl.cc',
|
||||||
'tests/cefclient/browser/main_context_impl.h',
|
'tests/cefclient/browser/main_context_impl.h',
|
||||||
|
'tests/cefclient/browser/media_router_test.cc',
|
||||||
|
'tests/cefclient/browser/media_router_test.h',
|
||||||
'tests/cefclient/browser/osr_dragdrop_events.h',
|
'tests/cefclient/browser/osr_dragdrop_events.h',
|
||||||
'tests/cefclient/browser/osr_renderer.h',
|
'tests/cefclient/browser/osr_renderer.h',
|
||||||
'tests/cefclient/browser/osr_renderer.cc',
|
'tests/cefclient/browser/osr_renderer.cc',
|
||||||
@@ -248,19 +274,35 @@
|
|||||||
'tests/cefclient/browser/root_window_create.cc',
|
'tests/cefclient/browser/root_window_create.cc',
|
||||||
'tests/cefclient/browser/root_window_manager.cc',
|
'tests/cefclient/browser/root_window_manager.cc',
|
||||||
'tests/cefclient/browser/root_window_manager.h',
|
'tests/cefclient/browser/root_window_manager.h',
|
||||||
|
'tests/cefclient/browser/root_window_views.cc',
|
||||||
|
'tests/cefclient/browser/root_window_views.h',
|
||||||
'tests/cefclient/browser/scheme_test.cc',
|
'tests/cefclient/browser/scheme_test.cc',
|
||||||
'tests/cefclient/browser/scheme_test.h',
|
'tests/cefclient/browser/scheme_test.h',
|
||||||
'tests/cefclient/browser/server_test.cc',
|
'tests/cefclient/browser/server_test.cc',
|
||||||
'tests/cefclient/browser/server_test.h',
|
'tests/cefclient/browser/server_test.h',
|
||||||
|
'tests/cefclient/browser/task_manager_test.cc',
|
||||||
|
'tests/cefclient/browser/task_manager_test.h',
|
||||||
'tests/cefclient/browser/temp_window.h',
|
'tests/cefclient/browser/temp_window.h',
|
||||||
'tests/cefclient/browser/test_runner.cc',
|
'tests/cefclient/browser/test_runner.cc',
|
||||||
'tests/cefclient/browser/test_runner.h',
|
'tests/cefclient/browser/test_runner.h',
|
||||||
'tests/cefclient/browser/urlrequest_test.cc',
|
'tests/cefclient/browser/urlrequest_test.cc',
|
||||||
'tests/cefclient/browser/urlrequest_test.h',
|
'tests/cefclient/browser/urlrequest_test.h',
|
||||||
|
'tests/cefclient/browser/views_menu_bar.cc',
|
||||||
|
'tests/cefclient/browser/views_menu_bar.h',
|
||||||
|
'tests/cefclient/browser/views_overlay_browser.cc',
|
||||||
|
'tests/cefclient/browser/views_overlay_browser.h',
|
||||||
|
'tests/cefclient/browser/views_overlay_controls.cc',
|
||||||
|
'tests/cefclient/browser/views_overlay_controls.h',
|
||||||
|
'tests/cefclient/browser/views_style.cc',
|
||||||
|
'tests/cefclient/browser/views_style.h',
|
||||||
|
'tests/cefclient/browser/views_window.cc',
|
||||||
|
'tests/cefclient/browser/views_window.h',
|
||||||
'tests/cefclient/browser/window_test.cc',
|
'tests/cefclient/browser/window_test.cc',
|
||||||
'tests/cefclient/browser/window_test.h',
|
'tests/cefclient/browser/window_test.h',
|
||||||
'tests/cefclient/browser/window_test_runner.cc',
|
'tests/cefclient/browser/window_test_runner.cc',
|
||||||
'tests/cefclient/browser/window_test_runner.h',
|
'tests/cefclient/browser/window_test_runner.h',
|
||||||
|
'tests/cefclient/browser/window_test_runner_views.cc',
|
||||||
|
'tests/cefclient/browser/window_test_runner_views.h',
|
||||||
],
|
],
|
||||||
'cefclient_sources_common': [
|
'cefclient_sources_common': [
|
||||||
'tests/cefclient/common/client_app_delegates_common.cc',
|
'tests/cefclient/common/client_app_delegates_common.cc',
|
||||||
@@ -271,18 +313,23 @@
|
|||||||
'tests/cefclient/renderer/client_app_delegates_renderer.cc',
|
'tests/cefclient/renderer/client_app_delegates_renderer.cc',
|
||||||
'tests/cefclient/renderer/client_renderer.cc',
|
'tests/cefclient/renderer/client_renderer.cc',
|
||||||
'tests/cefclient/renderer/client_renderer.h',
|
'tests/cefclient/renderer/client_renderer.h',
|
||||||
|
'tests/cefclient/renderer/ipc_performance_test.cc',
|
||||||
|
'tests/cefclient/renderer/ipc_performance_test.h',
|
||||||
'tests/cefclient/renderer/performance_test.cc',
|
'tests/cefclient/renderer/performance_test.cc',
|
||||||
'tests/cefclient/renderer/performance_test.h',
|
'tests/cefclient/renderer/performance_test.h',
|
||||||
'tests/cefclient/renderer/performance_test_setup.h',
|
'tests/cefclient/renderer/performance_test_setup.h',
|
||||||
'tests/cefclient/renderer/performance_test_tests.cc',
|
'tests/cefclient/renderer/performance_test_tests.cc',
|
||||||
],
|
],
|
||||||
'cefclient_sources_resources': [
|
'cefclient_sources_resources': [
|
||||||
|
'tests/cefclient/resources/binary_transfer.html',
|
||||||
'tests/cefclient/resources/binding.html',
|
'tests/cefclient/resources/binding.html',
|
||||||
'tests/cefclient/resources/dialogs.html',
|
'tests/cefclient/resources/dialogs.html',
|
||||||
'tests/cefclient/resources/draggable.html',
|
'tests/cefclient/resources/draggable.html',
|
||||||
'tests/cefclient/resources/drm.html',
|
'tests/cefclient/resources/hang.html',
|
||||||
|
'tests/cefclient/resources/ipc_performance.html',
|
||||||
'tests/cefclient/resources/localstorage.html',
|
'tests/cefclient/resources/localstorage.html',
|
||||||
'tests/cefclient/resources/logo.png',
|
'tests/cefclient/resources/logo.png',
|
||||||
|
'tests/cefclient/resources/media_router.html',
|
||||||
'tests/cefclient/resources/menu_icon.1x.png',
|
'tests/cefclient/resources/menu_icon.1x.png',
|
||||||
'tests/cefclient/resources/menu_icon.2x.png',
|
'tests/cefclient/resources/menu_icon.2x.png',
|
||||||
'tests/cefclient/resources/other_tests.html',
|
'tests/cefclient/resources/other_tests.html',
|
||||||
@@ -291,19 +338,13 @@
|
|||||||
'tests/cefclient/resources/preferences.html',
|
'tests/cefclient/resources/preferences.html',
|
||||||
'tests/cefclient/resources/response_filter.html',
|
'tests/cefclient/resources/response_filter.html',
|
||||||
'tests/cefclient/resources/server.html',
|
'tests/cefclient/resources/server.html',
|
||||||
|
'tests/cefclient/resources/task_manager.html',
|
||||||
'tests/cefclient/resources/transparency.html',
|
'tests/cefclient/resources/transparency.html',
|
||||||
'tests/cefclient/resources/urlrequest.html',
|
'tests/cefclient/resources/urlrequest.html',
|
||||||
'tests/cefclient/resources/websocket.html',
|
'tests/cefclient/resources/websocket.html',
|
||||||
'tests/cefclient/resources/window.html',
|
'tests/cefclient/resources/window.html',
|
||||||
'tests/cefclient/resources/xmlhttprequest.html',
|
'tests/cefclient/resources/xmlhttprequest.html',
|
||||||
],
|
],
|
||||||
'cefclient_sources_resources_extensions_set_page_color': [
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/icon.png',
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/manifest.json',
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/popup.html',
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/popup.js',
|
|
||||||
'tests/cefclient/resources/extensions/set_page_color/README.md',
|
|
||||||
],
|
|
||||||
'cefclient_sources_win': [
|
'cefclient_sources_win': [
|
||||||
'tests/cefclient/browser/browser_window_osr_win.cc',
|
'tests/cefclient/browser/browser_window_osr_win.cc',
|
||||||
'tests/cefclient/browser/browser_window_osr_win.h',
|
'tests/cefclient/browser/browser_window_osr_win.h',
|
||||||
@@ -332,27 +373,21 @@
|
|||||||
'tests/cefclient/browser/osr_window_win.cc',
|
'tests/cefclient/browser/osr_window_win.cc',
|
||||||
'tests/cefclient/browser/osr_window_win.h',
|
'tests/cefclient/browser/osr_window_win.h',
|
||||||
'tests/cefclient/browser/resource_util_win_idmap.cc',
|
'tests/cefclient/browser/resource_util_win_idmap.cc',
|
||||||
'tests/cefclient/browser/root_window_views.cc',
|
|
||||||
'tests/cefclient/browser/root_window_views.h',
|
|
||||||
'tests/cefclient/browser/root_window_win.cc',
|
'tests/cefclient/browser/root_window_win.cc',
|
||||||
'tests/cefclient/browser/root_window_win.h',
|
'tests/cefclient/browser/root_window_win.h',
|
||||||
'tests/cefclient/browser/temp_window_win.cc',
|
'tests/cefclient/browser/temp_window_win.cc',
|
||||||
'tests/cefclient/browser/temp_window_win.h',
|
'tests/cefclient/browser/temp_window_win.h',
|
||||||
'tests/cefclient/browser/views_menu_bar.cc',
|
|
||||||
'tests/cefclient/browser/views_menu_bar.h',
|
|
||||||
'tests/cefclient/browser/views_style.cc',
|
|
||||||
'tests/cefclient/browser/views_style.h',
|
|
||||||
'tests/cefclient/browser/views_window.cc',
|
|
||||||
'tests/cefclient/browser/views_window.h',
|
|
||||||
'tests/cefclient/browser/window_test_runner_views.cc',
|
|
||||||
'tests/cefclient/browser/window_test_runner_views.h',
|
|
||||||
'tests/cefclient/browser/window_test_runner_win.cc',
|
'tests/cefclient/browser/window_test_runner_win.cc',
|
||||||
'tests/cefclient/browser/window_test_runner_win.h',
|
'tests/cefclient/browser/window_test_runner_win.h',
|
||||||
'tests/cefclient/cefclient_win.cc',
|
'tests/cefclient/cefclient_win.cc',
|
||||||
'tests/cefclient/resources/win/cefclient.exe.manifest',
|
],
|
||||||
'tests/cefclient/resources/win/cefclient.ico',
|
'cefclient_sources_resources_win': [
|
||||||
'tests/cefclient/resources/win/cefclient.rc',
|
'tests/cefclient/win/cefclient.exe.manifest',
|
||||||
'tests/cefclient/resources/win/small.ico',
|
'tests/cefclient/win/cefclient.ico',
|
||||||
|
'tests/cefclient/win/small.ico',
|
||||||
|
],
|
||||||
|
'cefclient_sources_resources_win_rc': [
|
||||||
|
'tests/cefclient/win/cefclient.rc',
|
||||||
],
|
],
|
||||||
'cefclient_sources_mac': [
|
'cefclient_sources_mac': [
|
||||||
'tests/cefclient/browser/browser_window_osr_mac.h',
|
'tests/cefclient/browser/browser_window_osr_mac.h',
|
||||||
@@ -371,15 +406,16 @@
|
|||||||
'tests/cefclient/browser/temp_window_mac.mm',
|
'tests/cefclient/browser/temp_window_mac.mm',
|
||||||
'tests/cefclient/browser/text_input_client_osr_mac.h',
|
'tests/cefclient/browser/text_input_client_osr_mac.h',
|
||||||
'tests/cefclient/browser/text_input_client_osr_mac.mm',
|
'tests/cefclient/browser/text_input_client_osr_mac.mm',
|
||||||
|
'tests/cefclient/browser/views_window_mac.mm',
|
||||||
'tests/cefclient/browser/window_test_runner_mac.h',
|
'tests/cefclient/browser/window_test_runner_mac.h',
|
||||||
'tests/cefclient/browser/window_test_runner_mac.mm',
|
'tests/cefclient/browser/window_test_runner_mac.mm',
|
||||||
'tests/cefclient/cefclient_mac.mm',
|
'tests/cefclient/cefclient_mac.mm',
|
||||||
],
|
],
|
||||||
'cefclient_bundle_resources_mac': [
|
'cefclient_bundle_resources_mac': [
|
||||||
'tests/cefclient/resources/mac/cefclient.icns',
|
'tests/cefclient/mac/cefclient.icns',
|
||||||
'tests/cefclient/resources/mac/English.lproj/InfoPlist.strings',
|
'tests/cefclient/mac/English.lproj/InfoPlist.strings',
|
||||||
'tests/cefclient/resources/mac/English.lproj/MainMenu.xib',
|
'tests/cefclient/mac/English.lproj/MainMenu.xib',
|
||||||
'tests/cefclient/resources/mac/Info.plist',
|
'tests/cefclient/mac/Info.plist.in',
|
||||||
],
|
],
|
||||||
'cefclient_sources_linux': [
|
'cefclient_sources_linux': [
|
||||||
'tests/cefclient/browser/browser_window_osr_gtk.cc',
|
'tests/cefclient/browser/browser_window_osr_gtk.cc',
|
||||||
@@ -396,22 +432,12 @@
|
|||||||
'tests/cefclient/browser/resource_util_linux.cc',
|
'tests/cefclient/browser/resource_util_linux.cc',
|
||||||
'tests/cefclient/browser/root_window_gtk.cc',
|
'tests/cefclient/browser/root_window_gtk.cc',
|
||||||
'tests/cefclient/browser/root_window_gtk.h',
|
'tests/cefclient/browser/root_window_gtk.h',
|
||||||
'tests/cefclient/browser/root_window_views.cc',
|
|
||||||
'tests/cefclient/browser/root_window_views.h',
|
|
||||||
'tests/cefclient/browser/temp_window_x11.cc',
|
'tests/cefclient/browser/temp_window_x11.cc',
|
||||||
'tests/cefclient/browser/temp_window_x11.h',
|
'tests/cefclient/browser/temp_window_x11.h',
|
||||||
'tests/cefclient/browser/util_gtk.cc',
|
'tests/cefclient/browser/util_gtk.cc',
|
||||||
'tests/cefclient/browser/util_gtk.h',
|
'tests/cefclient/browser/util_gtk.h',
|
||||||
'tests/cefclient/browser/views_menu_bar.cc',
|
|
||||||
'tests/cefclient/browser/views_menu_bar.h',
|
|
||||||
'tests/cefclient/browser/views_style.cc',
|
|
||||||
'tests/cefclient/browser/views_style.h',
|
|
||||||
'tests/cefclient/browser/views_window.cc',
|
|
||||||
'tests/cefclient/browser/views_window.h',
|
|
||||||
'tests/cefclient/browser/window_test_runner_gtk.cc',
|
'tests/cefclient/browser/window_test_runner_gtk.cc',
|
||||||
'tests/cefclient/browser/window_test_runner_gtk.h',
|
'tests/cefclient/browser/window_test_runner_gtk.h',
|
||||||
'tests/cefclient/browser/window_test_runner_views.cc',
|
|
||||||
'tests/cefclient/browser/window_test_runner_views.h',
|
|
||||||
'tests/cefclient/cefclient_gtk.cc',
|
'tests/cefclient/cefclient_gtk.cc',
|
||||||
],
|
],
|
||||||
'cefsimple_sources_common': [
|
'cefsimple_sources_common': [
|
||||||
@@ -421,13 +447,17 @@
|
|||||||
'tests/cefsimple/simple_handler.h',
|
'tests/cefsimple/simple_handler.h',
|
||||||
],
|
],
|
||||||
'cefsimple_sources_win': [
|
'cefsimple_sources_win': [
|
||||||
'tests/cefsimple/cefsimple.exe.manifest',
|
|
||||||
'tests/cefsimple/cefsimple.rc',
|
|
||||||
'tests/cefsimple/cefsimple_win.cc',
|
'tests/cefsimple/cefsimple_win.cc',
|
||||||
'tests/cefsimple/simple_handler_win.cc',
|
|
||||||
'tests/cefsimple/resource.h',
|
'tests/cefsimple/resource.h',
|
||||||
'tests/cefsimple/res/cefsimple.ico',
|
'tests/cefsimple/simple_handler_win.cc',
|
||||||
'tests/cefsimple/res/small.ico',
|
],
|
||||||
|
'cefsimple_sources_resources_win': [
|
||||||
|
'tests/cefsimple/win/cefsimple.exe.manifest',
|
||||||
|
'tests/cefsimple/win/cefsimple.ico',
|
||||||
|
'tests/cefsimple/win/small.ico',
|
||||||
|
],
|
||||||
|
'cefsimple_sources_resources_win_rc': [
|
||||||
|
'tests/cefsimple/win/cefsimple.rc',
|
||||||
],
|
],
|
||||||
'cefsimple_sources_mac': [
|
'cefsimple_sources_mac': [
|
||||||
'tests/cefsimple/cefsimple_mac.mm',
|
'tests/cefsimple/cefsimple_mac.mm',
|
||||||
@@ -440,57 +470,73 @@
|
|||||||
'tests/cefsimple/mac/cefsimple.icns',
|
'tests/cefsimple/mac/cefsimple.icns',
|
||||||
'tests/cefsimple/mac/English.lproj/InfoPlist.strings',
|
'tests/cefsimple/mac/English.lproj/InfoPlist.strings',
|
||||||
'tests/cefsimple/mac/English.lproj/MainMenu.xib',
|
'tests/cefsimple/mac/English.lproj/MainMenu.xib',
|
||||||
'tests/cefsimple/mac/Info.plist',
|
'tests/cefsimple/mac/Info.plist.in',
|
||||||
],
|
],
|
||||||
'cefsimple_sources_linux': [
|
'cefsimple_sources_linux': [
|
||||||
'tests/cefsimple/cefsimple_linux.cc',
|
'tests/cefsimple/cefsimple_linux.cc',
|
||||||
'tests/cefsimple/simple_handler_linux.cc',
|
'tests/cefsimple/simple_handler_linux.cc',
|
||||||
],
|
],
|
||||||
|
'ceftests_data_resources': [
|
||||||
|
'tests/ceftests/resources/net/data/ssl/certificates/expired_cert.pem',
|
||||||
|
'tests/ceftests/resources/net/data/ssl/certificates/localhost_cert.pem',
|
||||||
|
'tests/ceftests/resources/net/data/ssl/certificates/ok_cert.pem',
|
||||||
|
'tests/ceftests/resources/net/data/ssl/certificates/root_ca_cert.pem',
|
||||||
|
],
|
||||||
'ceftests_sources_common': [
|
'ceftests_sources_common': [
|
||||||
'tests/ceftests/audio_output_unittest.cc',
|
'tests/ceftests/audio_output_unittest.cc',
|
||||||
'tests/ceftests/browser_info_map_unittest.cc',
|
'tests/ceftests/browser_info_map_unittest.cc',
|
||||||
|
'tests/ceftests/certificate_error_unittest.cc',
|
||||||
'tests/ceftests/command_line_unittest.cc',
|
'tests/ceftests/command_line_unittest.cc',
|
||||||
'tests/ceftests/cookie_unittest.cc',
|
'tests/ceftests/cookie_unittest.cc',
|
||||||
|
'tests/ceftests/cors_unittest.cc',
|
||||||
|
'tests/ceftests/devtools_message_unittest.cc',
|
||||||
'tests/ceftests/dialog_unittest.cc',
|
'tests/ceftests/dialog_unittest.cc',
|
||||||
'tests/ceftests/display_unittest.cc',
|
'tests/ceftests/display_unittest.cc',
|
||||||
'tests/ceftests/dom_unittest.cc',
|
'tests/ceftests/dom_unittest.cc',
|
||||||
'tests/ceftests/download_unittest.cc',
|
'tests/ceftests/download_unittest.cc',
|
||||||
'tests/ceftests/draggable_regions_unittest.cc',
|
'tests/ceftests/draggable_regions_unittest.cc',
|
||||||
'tests/ceftests/extensions/background_unittest.cc',
|
|
||||||
'tests/ceftests/extensions/chrome_alarms_unittest.cc',
|
|
||||||
'tests/ceftests/extensions/chrome_storage_unittest.cc',
|
|
||||||
'tests/ceftests/extensions/chrome_tabs_unittest.cc',
|
|
||||||
'tests/ceftests/extensions/extension_test_handler.cc',
|
|
||||||
'tests/ceftests/extensions/extension_test_handler.h',
|
|
||||||
'tests/ceftests/extensions/view_unittest.cc',
|
|
||||||
'tests/ceftests/file_util_unittest.cc',
|
'tests/ceftests/file_util_unittest.cc',
|
||||||
|
'tests/ceftests/frame_handler_unittest.cc',
|
||||||
'tests/ceftests/frame_unittest.cc',
|
'tests/ceftests/frame_unittest.cc',
|
||||||
|
'tests/ceftests/hsts_redirect_unittest.cc',
|
||||||
'tests/ceftests/image_unittest.cc',
|
'tests/ceftests/image_unittest.cc',
|
||||||
'tests/ceftests/image_util.cc',
|
'tests/ceftests/image_util.cc',
|
||||||
'tests/ceftests/image_util.h',
|
'tests/ceftests/image_util.h',
|
||||||
'tests/ceftests/jsdialog_unittest.cc',
|
'tests/ceftests/jsdialog_unittest.cc',
|
||||||
'tests/ceftests/life_span_unittest.cc',
|
'tests/ceftests/life_span_unittest.cc',
|
||||||
'tests/ceftests/message_router_unittest.cc',
|
'tests/ceftests/media_access_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_binary_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_harness_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_multi_query_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_single_query_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_threshold_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_unittest_utils.cc',
|
||||||
|
'tests/ceftests/message_router_unittest_utils.h',
|
||||||
'tests/ceftests/navigation_unittest.cc',
|
'tests/ceftests/navigation_unittest.cc',
|
||||||
'tests/ceftests/os_rendering_unittest.cc',
|
'tests/ceftests/os_rendering_unittest.cc',
|
||||||
'tests/ceftests/osr_accessibility_unittest.cc',
|
'tests/ceftests/osr_accessibility_unittest.cc',
|
||||||
'tests/ceftests/osr_display_unittest.cc',
|
'tests/ceftests/osr_display_unittest.cc',
|
||||||
'tests/ceftests/parser_unittest.cc',
|
'tests/ceftests/parser_unittest.cc',
|
||||||
'tests/ceftests/plugin_unittest.cc',
|
'tests/ceftests/pdf_viewer_unittest.cc',
|
||||||
|
'tests/ceftests/permission_prompt_unittest.cc',
|
||||||
'tests/ceftests/preference_unittest.cc',
|
'tests/ceftests/preference_unittest.cc',
|
||||||
'tests/ceftests/print_unittest.cc',
|
'tests/ceftests/print_unittest.cc',
|
||||||
'tests/ceftests/process_message_unittest.cc',
|
'tests/ceftests/process_message_unittest.cc',
|
||||||
'tests/ceftests/request_context_unittest.cc',
|
'tests/ceftests/request_context_unittest.cc',
|
||||||
'tests/ceftests/request_handler_unittest.cc',
|
'tests/ceftests/request_handler_unittest.cc',
|
||||||
'tests/ceftests/request_unittest.cc',
|
'tests/ceftests/request_unittest.cc',
|
||||||
|
'tests/ceftests/response_unittest.cc',
|
||||||
'tests/ceftests/resource.h',
|
'tests/ceftests/resource.h',
|
||||||
'tests/ceftests/resource_manager_unittest.cc',
|
'tests/ceftests/resource_manager_unittest.cc',
|
||||||
|
'tests/ceftests/resource_request_handler_unittest.cc',
|
||||||
'tests/ceftests/routing_test_handler.cc',
|
'tests/ceftests/routing_test_handler.cc',
|
||||||
'tests/ceftests/routing_test_handler.h',
|
'tests/ceftests/routing_test_handler.h',
|
||||||
'tests/ceftests/run_all_unittests.cc',
|
'tests/ceftests/run_all_unittests.cc',
|
||||||
'tests/ceftests/scheme_handler_unittest.cc',
|
'tests/ceftests/scheme_handler_unittest.cc',
|
||||||
'tests/ceftests/scoped_temp_dir_unittest.cc',
|
'tests/ceftests/scoped_temp_dir_unittest.cc',
|
||||||
'tests/ceftests/server_unittest.cc',
|
'tests/ceftests/server_unittest.cc',
|
||||||
|
'tests/ceftests/send_shared_process_message_unittest.cc',
|
||||||
|
"tests/ceftests/shared_process_message_unittest.cc",
|
||||||
'tests/ceftests/stream_unittest.cc',
|
'tests/ceftests/stream_unittest.cc',
|
||||||
'tests/ceftests/stream_resource_handler_unittest.cc',
|
'tests/ceftests/stream_resource_handler_unittest.cc',
|
||||||
'tests/ceftests/string_unittest.cc',
|
'tests/ceftests/string_unittest.cc',
|
||||||
@@ -498,25 +544,35 @@
|
|||||||
'tests/ceftests/task_unittest.cc',
|
'tests/ceftests/task_unittest.cc',
|
||||||
'tests/ceftests/test_handler.cc',
|
'tests/ceftests/test_handler.cc',
|
||||||
'tests/ceftests/test_handler.h',
|
'tests/ceftests/test_handler.h',
|
||||||
|
'tests/ceftests/test_request.cc',
|
||||||
|
'tests/ceftests/test_request.h',
|
||||||
|
'tests/ceftests/test_server.cc',
|
||||||
|
'tests/ceftests/test_server.h',
|
||||||
|
'tests/ceftests/test_server_observer.h',
|
||||||
|
'tests/ceftests/test_server_observer.cc',
|
||||||
|
'tests/ceftests/test_server_observer_unittest.cc',
|
||||||
|
'tests/ceftests/test_server_manager.h',
|
||||||
|
'tests/ceftests/test_server_manager.cc',
|
||||||
|
'tests/ceftests/test_server_runner.h',
|
||||||
|
'tests/ceftests/test_server_runner.cc',
|
||||||
|
'tests/ceftests/test_server_runner_normal.cc',
|
||||||
|
'tests/ceftests/test_server_runner_test.cc',
|
||||||
|
'tests/ceftests/test_server_unittest.cc',
|
||||||
'tests/ceftests/test_suite.cc',
|
'tests/ceftests/test_suite.cc',
|
||||||
'tests/ceftests/test_suite.h',
|
'tests/ceftests/test_suite.h',
|
||||||
'tests/ceftests/test_util.cc',
|
'tests/ceftests/test_util.cc',
|
||||||
'tests/ceftests/test_util.h',
|
'tests/ceftests/test_util.h',
|
||||||
|
'tests/ceftests/time_unittest.cc',
|
||||||
'tests/ceftests/thread_helper.cc',
|
'tests/ceftests/thread_helper.cc',
|
||||||
'tests/ceftests/thread_helper.h',
|
'tests/ceftests/thread_helper.h',
|
||||||
'tests/ceftests/thread_unittest.cc',
|
'tests/ceftests/thread_unittest.cc',
|
||||||
'tests/ceftests/tracing_unittest.cc',
|
'tests/ceftests/tracing_unittest.cc',
|
||||||
|
'tests/ceftests/track_callback.h',
|
||||||
'tests/ceftests/translator_unittest.cc',
|
'tests/ceftests/translator_unittest.cc',
|
||||||
'tests/ceftests/urlrequest_unittest.cc',
|
'tests/ceftests/urlrequest_unittest.cc',
|
||||||
'tests/ceftests/v8_unittest.cc',
|
'tests/ceftests/v8_unittest.cc',
|
||||||
'tests/ceftests/values_unittest.cc',
|
'tests/ceftests/values_unittest.cc',
|
||||||
'tests/ceftests/version_unittest.cc',
|
'tests/ceftests/version_unittest.cc',
|
||||||
'tests/ceftests/waitable_event_unittest.cc',
|
|
||||||
'tests/ceftests/webui_unittest.cc',
|
|
||||||
'tests/ceftests/xml_reader_unittest.cc',
|
|
||||||
'tests/ceftests/zip_reader_unittest.cc',
|
|
||||||
],
|
|
||||||
'ceftests_sources_views': [
|
|
||||||
'tests/ceftests/views/button_unittest.cc',
|
'tests/ceftests/views/button_unittest.cc',
|
||||||
'tests/ceftests/views/panel_unittest.cc',
|
'tests/ceftests/views/panel_unittest.cc',
|
||||||
'tests/ceftests/views/scroll_view_unittest.cc',
|
'tests/ceftests/views/scroll_view_unittest.cc',
|
||||||
@@ -524,46 +580,88 @@
|
|||||||
'tests/ceftests/views/test_window_delegate.h',
|
'tests/ceftests/views/test_window_delegate.h',
|
||||||
'tests/ceftests/views/textfield_unittest.cc',
|
'tests/ceftests/views/textfield_unittest.cc',
|
||||||
'tests/ceftests/views/window_unittest.cc',
|
'tests/ceftests/views/window_unittest.cc',
|
||||||
|
'tests/ceftests/waitable_event_unittest.cc',
|
||||||
|
'tests/ceftests/webui_unittest.cc',
|
||||||
|
'tests/ceftests/xml_reader_unittest.cc',
|
||||||
|
'tests/ceftests/zip_reader_unittest.cc',
|
||||||
],
|
],
|
||||||
'ceftests_sources_win': [
|
'ceftests_sources_win': [
|
||||||
|
'tests/ceftests/resource_util_win_dir.cc',
|
||||||
'tests/ceftests/resource_util_win_idmap.cc',
|
'tests/ceftests/resource_util_win_idmap.cc',
|
||||||
'tests/ceftests/resources/win/ceftests.exe.manifest',
|
],
|
||||||
'tests/ceftests/resources/win/ceftests.ico',
|
'ceftests_sources_resources_win': [
|
||||||
'tests/ceftests/resources/win/ceftests.rc',
|
'tests/ceftests/win/ceftests.exe.manifest',
|
||||||
'tests/ceftests/resources/win/small.ico',
|
'tests/ceftests/win/ceftests.ico',
|
||||||
|
'tests/ceftests/win/small.ico',
|
||||||
|
],
|
||||||
|
'ceftests_sources_resources_win_rc': [
|
||||||
|
'tests/ceftests/win/ceftests.rc',
|
||||||
],
|
],
|
||||||
'ceftests_sources_mac': [
|
'ceftests_sources_mac': [
|
||||||
'tests/ceftests/os_rendering_unittest_mac.h',
|
'tests/ceftests/os_rendering_unittest_mac.h',
|
||||||
'tests/ceftests/os_rendering_unittest_mac.mm',
|
'tests/ceftests/os_rendering_unittest_mac.mm',
|
||||||
'tests/ceftests/run_all_unittests_mac.mm',
|
'tests/ceftests/run_all_unittests_mac.mm',
|
||||||
],
|
],
|
||||||
'ceftests_sources_mac_helper': [
|
'ceftests_sources_mac_browser_shared': [
|
||||||
|
'tests/shared/renderer/client_app_renderer.h',
|
||||||
|
],
|
||||||
|
'ceftests_sources_mac_helper_shared': [
|
||||||
|
'tests/shared/browser/client_app_browser.h',
|
||||||
'tests/shared/browser/file_util.cc',
|
'tests/shared/browser/file_util.cc',
|
||||||
'tests/shared/browser/file_util.h',
|
'tests/shared/browser/file_util.h',
|
||||||
'tests/shared/browser/resource_util.h',
|
'tests/shared/browser/resource_util.h',
|
||||||
'tests/shared/browser/resource_util_mac.mm',
|
'tests/shared/browser/resource_util_mac.mm',
|
||||||
'tests/shared/browser/resource_util_posix.cc',
|
'tests/shared/browser/resource_util_posix.cc',
|
||||||
|
],
|
||||||
|
'ceftests_sources_mac_helper': [
|
||||||
|
'tests/ceftests/audio_output_unittest.cc',
|
||||||
'tests/ceftests/client_app_delegates.cc',
|
'tests/ceftests/client_app_delegates.cc',
|
||||||
'tests/ceftests/cookie_unittest.cc',
|
'tests/ceftests/cookie_unittest.cc',
|
||||||
|
'tests/ceftests/cors_unittest.cc',
|
||||||
'tests/ceftests/dom_unittest.cc',
|
'tests/ceftests/dom_unittest.cc',
|
||||||
'tests/ceftests/frame_unittest.cc',
|
'tests/ceftests/frame_unittest.cc',
|
||||||
'tests/ceftests/message_router_unittest.cc',
|
'tests/ceftests/media_access_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_binary_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_harness_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_multi_query_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_single_query_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_threshold_unittest.cc',
|
||||||
|
'tests/ceftests/message_router_unittest_utils.cc',
|
||||||
|
'tests/ceftests/message_router_unittest_utils.h',
|
||||||
'tests/ceftests/navigation_unittest.cc',
|
'tests/ceftests/navigation_unittest.cc',
|
||||||
'tests/ceftests/plugin_unittest.cc',
|
'tests/ceftests/pdf_viewer_unittest.cc',
|
||||||
|
'tests/ceftests/permission_prompt_unittest.cc',
|
||||||
'tests/ceftests/preference_unittest.cc',
|
'tests/ceftests/preference_unittest.cc',
|
||||||
'tests/ceftests/process_message_unittest.cc',
|
'tests/ceftests/process_message_unittest.cc',
|
||||||
'tests/ceftests/request_handler_unittest.cc',
|
'tests/ceftests/request_handler_unittest.cc',
|
||||||
'tests/ceftests/request_unittest.cc',
|
'tests/ceftests/request_unittest.cc',
|
||||||
|
'tests/ceftests/response_unittest.cc',
|
||||||
|
'tests/ceftests/resource_request_handler_unittest.cc',
|
||||||
'tests/ceftests/routing_test_handler.cc',
|
'tests/ceftests/routing_test_handler.cc',
|
||||||
'tests/ceftests/routing_test_handler.h',
|
'tests/ceftests/routing_test_handler.h',
|
||||||
'tests/ceftests/scheme_handler_unittest.cc',
|
'tests/ceftests/scheme_handler_unittest.cc',
|
||||||
|
'tests/ceftests/send_shared_process_message_unittest.cc',
|
||||||
|
"tests/ceftests/shared_process_message_unittest.cc",
|
||||||
'tests/ceftests/urlrequest_unittest.cc',
|
'tests/ceftests/urlrequest_unittest.cc',
|
||||||
'tests/ceftests/test_handler.cc',
|
'tests/ceftests/test_handler.cc',
|
||||||
'tests/ceftests/test_handler.h',
|
'tests/ceftests/test_handler.h',
|
||||||
|
'tests/ceftests/test_request.cc',
|
||||||
|
'tests/ceftests/test_request.h',
|
||||||
|
'tests/ceftests/test_server.cc',
|
||||||
|
'tests/ceftests/test_server.h',
|
||||||
|
'tests/ceftests/test_server_observer.h',
|
||||||
|
'tests/ceftests/test_server_observer.cc',
|
||||||
|
'tests/ceftests/test_server_manager.h',
|
||||||
|
'tests/ceftests/test_server_manager.cc',
|
||||||
|
'tests/ceftests/test_server_runner.h',
|
||||||
|
'tests/ceftests/test_server_runner.cc',
|
||||||
|
'tests/ceftests/test_server_runner_normal.cc',
|
||||||
|
'tests/ceftests/test_server_runner_test.cc',
|
||||||
'tests/ceftests/test_suite.cc',
|
'tests/ceftests/test_suite.cc',
|
||||||
'tests/ceftests/test_suite.h',
|
'tests/ceftests/test_suite.h',
|
||||||
'tests/ceftests/test_util.cc',
|
'tests/ceftests/test_util.cc',
|
||||||
'tests/ceftests/test_util.h',
|
'tests/ceftests/test_util.h',
|
||||||
|
'tests/ceftests/track_callback.h',
|
||||||
'tests/ceftests/thread_helper.cc',
|
'tests/ceftests/thread_helper.cc',
|
||||||
'tests/ceftests/thread_helper.h',
|
'tests/ceftests/thread_helper.h',
|
||||||
'tests/ceftests/thread_unittest.cc',
|
'tests/ceftests/thread_unittest.cc',
|
||||||
@@ -571,10 +669,10 @@
|
|||||||
'tests/ceftests/v8_unittest.cc',
|
'tests/ceftests/v8_unittest.cc',
|
||||||
],
|
],
|
||||||
'ceftests_bundle_resources_mac': [
|
'ceftests_bundle_resources_mac': [
|
||||||
'tests/ceftests/resources/mac/ceftests.icns',
|
'tests/ceftests/mac/ceftests.icns',
|
||||||
'tests/ceftests/resources/mac/English.lproj/InfoPlist.strings',
|
'tests/ceftests/mac/English.lproj/InfoPlist.strings',
|
||||||
'tests/ceftests/resources/mac/English.lproj/MainMenu.xib',
|
'tests/ceftests/mac/English.lproj/MainMenu.xib',
|
||||||
'tests/ceftests/resources/mac/Info.plist',
|
'tests/ceftests/mac/Info.plist.in',
|
||||||
],
|
],
|
||||||
'ceftests_sources_linux': [
|
'ceftests_sources_linux': [
|
||||||
'tests/ceftests/resource_util_linux.cc',
|
'tests/ceftests/resource_util_linux.cc',
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
# Copyright 2016 The Chromium Embedded Framework Authors. Portions copyright
|
|
||||||
# 2014 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.
|
|
||||||
#
|
|
||||||
# This is a copy of src/chrome/chrome_repack_locales.gni with the necessary
|
|
||||||
# modifications to meet CEF's requirements.
|
|
||||||
|
|
||||||
import("//build/config/chrome_build.gni")
|
|
||||||
import("//build/config/features.gni")
|
|
||||||
import("//build/config/ui.gni")
|
|
||||||
import("//tools/grit/repack.gni")
|
|
||||||
|
|
||||||
# Arguments:
|
|
||||||
#
|
|
||||||
# locale
|
|
||||||
# Internal name of locale. e.g. "pt-BR"
|
|
||||||
#
|
|
||||||
# output
|
|
||||||
# Output file name.
|
|
||||||
#
|
|
||||||
# visibility
|
|
||||||
# Normal meaning.
|
|
||||||
template("_repack_one_locale") {
|
|
||||||
locale = invoker.locale
|
|
||||||
|
|
||||||
repack(target_name) {
|
|
||||||
visibility = invoker.visibility
|
|
||||||
|
|
||||||
# Each input pak file should also have a deps line for completeness.
|
|
||||||
# Add associated .h files in the make_pack_header("strings") target.
|
|
||||||
sources = [
|
|
||||||
"${root_gen_dir}/cef/cef_strings_${locale}.pak",
|
|
||||||
"${root_gen_dir}/chrome/chromium_strings_${locale}.pak",
|
|
||||||
"${root_gen_dir}/chrome/generated_resources_${locale}.pak",
|
|
||||||
"${root_gen_dir}/chrome/locale_settings_${locale}.pak",
|
|
||||||
"${root_gen_dir}/chrome/platform_locale_settings_${locale}.pak",
|
|
||||||
"${root_gen_dir}/components/strings/components_locale_settings_${locale}.pak",
|
|
||||||
"${root_gen_dir}/components/strings/components_strings_${locale}.pak",
|
|
||||||
"${root_gen_dir}/content/app/strings/content_strings_${locale}.pak",
|
|
||||||
"${root_gen_dir}/extensions/strings/extensions_strings_${locale}.pak",
|
|
||||||
"${root_gen_dir}/ui/strings/app_locale_settings_${locale}.pak",
|
|
||||||
"${root_gen_dir}/ui/strings/ui_strings_${locale}.pak",
|
|
||||||
]
|
|
||||||
|
|
||||||
# Use public_deps so that generated grit headers are discoverable from
|
|
||||||
# the libcef_static target. Grit deps that generate .cc files must be
|
|
||||||
# listed both here and in the libcef_static target.
|
|
||||||
public_deps = [
|
|
||||||
":cef_strings",
|
|
||||||
"//chrome/app:chromium_strings",
|
|
||||||
"//chrome/app:generated_resources",
|
|
||||||
"//chrome/app/resources:locale_settings",
|
|
||||||
"//chrome/app/resources:platform_locale_settings",
|
|
||||||
"//components/strings:components_locale_settings",
|
|
||||||
"//components/strings:components_strings",
|
|
||||||
"//content/app/strings",
|
|
||||||
"//extensions/strings",
|
|
||||||
"//ui/strings:app_locale_settings",
|
|
||||||
"//ui/strings:ui_strings",
|
|
||||||
]
|
|
||||||
|
|
||||||
output = invoker.output
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Creates an action to call the repack_locales script.
|
|
||||||
#
|
|
||||||
# The GYP version generates the locales in the "gen" directory and then copies
|
|
||||||
# it to the root build directory. This isn't easy to express in a GN copy
|
|
||||||
# rule since the files on Mac have a complex structure. So we generate the
|
|
||||||
# files into the final place and skip the "gen" directory.
|
|
||||||
#
|
|
||||||
# This template uses GN's looping constructs to avoid the complex call to
|
|
||||||
# chrome/tools/build/repack_locales.py which wraps the repack commands in the
|
|
||||||
# GYP build.
|
|
||||||
#
|
|
||||||
# Arguments
|
|
||||||
#
|
|
||||||
# input_locales
|
|
||||||
# List of locale names to use as inputs.
|
|
||||||
#
|
|
||||||
# output_locales
|
|
||||||
# A list containing the corresponding output names for each of the
|
|
||||||
# input names. Mac uses different names in some cases.
|
|
||||||
#
|
|
||||||
# visibility
|
|
||||||
template("cef_repack_locales") {
|
|
||||||
# This is the name of the group below that will collect all the invidual
|
|
||||||
# locale targets. External targets will depend on this.
|
|
||||||
group_target_name = target_name
|
|
||||||
|
|
||||||
# GN's subscript is too stupid to do invoker.output_locales[foo] so we need
|
|
||||||
# to make a copy and do output_locales[foo].
|
|
||||||
output_locales = invoker.output_locales
|
|
||||||
|
|
||||||
# Collects all targets the loop generates.
|
|
||||||
locale_targets = []
|
|
||||||
|
|
||||||
# This loop iterates over the input locales and also keeps a counter so it
|
|
||||||
# can simultaneously iterate over the output locales (using GN's very
|
|
||||||
# limited looping capabilities).
|
|
||||||
current_index = 0
|
|
||||||
foreach(input_locale, invoker.input_locales) {
|
|
||||||
output_locale = output_locales[current_index]
|
|
||||||
|
|
||||||
# Compute the name of the target for the current file. Save it for the deps.
|
|
||||||
current_name = "${target_name}_${input_locale}"
|
|
||||||
locale_targets += [ ":$current_name" ]
|
|
||||||
|
|
||||||
_repack_one_locale(current_name) {
|
|
||||||
visibility = [ ":$group_target_name" ]
|
|
||||||
locale = input_locale
|
|
||||||
|
|
||||||
# Compute the output name. Mac uses a different location.
|
|
||||||
if (is_mac || is_ios) {
|
|
||||||
output = "${root_gen_dir}/repack/locales/${output_locale}.pak"
|
|
||||||
} else {
|
|
||||||
output = "${root_out_dir}/locales/${output_locale}.pak"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current_index = current_index + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# The group that external targets depend on which collects all deps.
|
|
||||||
group(group_target_name) {
|
|
||||||
forward_variables_from(invoker, [ "visibility" ])
|
|
||||||
public_deps = locale_targets
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,7 @@ macro(PRINT_CEF_CONFIG)
|
|||||||
|
|
||||||
message(STATUS "Binary distribution root: ${_CEF_ROOT}")
|
message(STATUS "Binary distribution root: ${_CEF_ROOT}")
|
||||||
|
|
||||||
if(OS_MACOSX)
|
if(OS_MAC)
|
||||||
message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}")
|
message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}")
|
||||||
message(STATUS "Target SDK: ${CEF_TARGET_SDK}")
|
message(STATUS "Target SDK: ${CEF_TARGET_SDK}")
|
||||||
endif()
|
endif()
|
||||||
@@ -75,8 +75,8 @@ macro(APPEND_PLATFORM_SOURCES name_of_list)
|
|||||||
if(OS_WINDOWS AND ${name_of_list}_WINDOWS)
|
if(OS_WINDOWS AND ${name_of_list}_WINDOWS)
|
||||||
list(APPEND ${name_of_list} ${${name_of_list}_WINDOWS})
|
list(APPEND ${name_of_list} ${${name_of_list}_WINDOWS})
|
||||||
endif()
|
endif()
|
||||||
if(OS_MACOSX AND ${name_of_list}_MACOSX)
|
if(OS_MAC AND ${name_of_list}_MAC)
|
||||||
list(APPEND ${name_of_list} ${${name_of_list}_MACOSX})
|
list(APPEND ${name_of_list} ${${name_of_list}_MAC})
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
@@ -95,43 +95,64 @@ macro(SET_CEF_TARGET_OUT_DIR)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Copy a list of files from one directory to another. Relative files paths are maintained.
|
# Copy a list of files from one directory to another. Relative file paths are maintained.
|
||||||
# The path component of the source |file_list| will be removed.
|
|
||||||
macro(COPY_FILES target file_list source_dir target_dir)
|
macro(COPY_FILES target file_list source_dir target_dir)
|
||||||
foreach(FILENAME ${file_list})
|
foreach(FILENAME ${file_list})
|
||||||
set(source_file ${source_dir}/${FILENAME})
|
set(source_file ${source_dir}/${FILENAME})
|
||||||
|
|
||||||
|
# Remove the target file path component.
|
||||||
get_filename_component(target_name ${FILENAME} NAME)
|
get_filename_component(target_name ${FILENAME} NAME)
|
||||||
set(target_file ${target_dir}/${target_name})
|
set(target_file ${target_dir}/${target_name})
|
||||||
|
|
||||||
string(FIND ${source_file} "$<CONFIGURATION>" _pos)
|
COPY_SINGLE_FILE(${target} ${source_file} ${target_file})
|
||||||
if(NOT ${_pos} EQUAL -1)
|
|
||||||
# Must test with an actual configuration directory.
|
|
||||||
string(REPLACE "$<CONFIGURATION>" "Release" existing_source_file ${source_file})
|
|
||||||
if(NOT EXISTS ${existing_source_file})
|
|
||||||
string(REPLACE "$<CONFIGURATION>" "Debug" existing_source_file ${source_file})
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(existing_source_file ${source_file})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(IS_DIRECTORY ${existing_source_file})
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${target}
|
|
||||||
POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${source_file}" "${target_file}"
|
|
||||||
VERBATIM
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${target}
|
|
||||||
POST_BUILD
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${source_file}" "${target_file}"
|
|
||||||
VERBATIM
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
# Copy a list of files from one directory to another. Relative file paths are maintained.
|
||||||
|
macro(COPY_RESOURCES target file_list prefix_list source_dir target_dir)
|
||||||
|
foreach(FILENAME ${file_list})
|
||||||
|
set(source_file ${source_dir}/${FILENAME})
|
||||||
|
|
||||||
|
# Remove one or more prefixes from the source paths.
|
||||||
|
set(TARGET_FILENAME "${FILENAME}")
|
||||||
|
foreach(PREFIX ${prefix_list})
|
||||||
|
string(REGEX REPLACE "^.*${PREFIX}" "" TARGET_FILENAME ${TARGET_FILENAME})
|
||||||
|
endforeach()
|
||||||
|
set(target_file ${target_dir}/${TARGET_FILENAME})
|
||||||
|
|
||||||
|
COPY_SINGLE_FILE(${target} ${source_file} ${target_file})
|
||||||
|
endforeach()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(COPY_SINGLE_FILE target source_file target_file)
|
||||||
|
string(FIND ${source_file} "$<CONFIGURATION>" _pos)
|
||||||
|
if(NOT ${_pos} EQUAL -1)
|
||||||
|
# Must test with an actual configuration directory.
|
||||||
|
string(REPLACE "$<CONFIGURATION>" "Release" existing_source_file ${source_file})
|
||||||
|
if(NOT EXISTS ${existing_source_file})
|
||||||
|
string(REPLACE "$<CONFIGURATION>" "Debug" existing_source_file ${source_file})
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(existing_source_file ${source_file})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(IS_DIRECTORY ${existing_source_file})
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${target}
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory "${source_file}" "${target_file}"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${target}
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${source_file}" "${target_file}"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Linux macros.
|
# Linux macros.
|
||||||
@@ -184,10 +205,10 @@ endif(OS_LINUX)
|
|||||||
# Mac OS X macros.
|
# Mac OS X macros.
|
||||||
#
|
#
|
||||||
|
|
||||||
if(OS_MACOSX)
|
if(OS_MAC)
|
||||||
|
|
||||||
# Manually process and copy over resource files.
|
# Manually process and copy over resource files.
|
||||||
macro(COPY_MACOSX_RESOURCES resource_list prefix_list target source_dir app_path)
|
macro(COPY_MAC_RESOURCES resource_list prefix_list target source_dir app_path)
|
||||||
foreach(FILENAME ${resource_list})
|
foreach(FILENAME ${resource_list})
|
||||||
# Remove one or more prefixes from the source paths.
|
# Remove one or more prefixes from the source paths.
|
||||||
set(TARGET_FILENAME "${FILENAME}")
|
set(TARGET_FILENAME "${FILENAME}")
|
||||||
@@ -229,7 +250,7 @@ macro(COPY_MACOSX_RESOURCES resource_list prefix_list target source_dir app_path
|
|||||||
endforeach()
|
endforeach()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
endif(OS_MACOSX)
|
endif(OS_MAC)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -298,7 +319,7 @@ macro(SET_COMMON_TARGET_PROPERTIES target)
|
|||||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
|
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OS_MACOSX)
|
if(OS_MAC)
|
||||||
# Set Xcode target properties.
|
# Set Xcode target properties.
|
||||||
set_target_properties(${target} PROPERTIES
|
set_target_properties(${target} PROPERTIES
|
||||||
XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO
|
XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ endif()
|
|||||||
|
|
||||||
# Determine the platform.
|
# Determine the platform.
|
||||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||||
set(OS_MACOSX 1)
|
set(OS_MAC 1)
|
||||||
|
set(OS_MACOSX 1) # For backwards compatibility.
|
||||||
set(OS_POSIX 1)
|
set(OS_POSIX 1)
|
||||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||||
set(OS_LINUX 1)
|
set(OS_LINUX 1)
|
||||||
@@ -25,16 +26,14 @@ endif()
|
|||||||
|
|
||||||
# Determine the project architecture.
|
# Determine the project architecture.
|
||||||
if(NOT DEFINED PROJECT_ARCH)
|
if(NOT DEFINED PROJECT_ARCH)
|
||||||
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
if(("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64") OR
|
||||||
|
("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM64"))
|
||||||
|
set(PROJECT_ARCH "arm64")
|
||||||
|
elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||||
set(PROJECT_ARCH "x86_64")
|
set(PROJECT_ARCH "x86_64")
|
||||||
else()
|
else()
|
||||||
set(PROJECT_ARCH "x86")
|
set(PROJECT_ARCH "x86")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OS_MACOSX)
|
|
||||||
# PROJECT_ARCH should be specified on Mac OS X.
|
|
||||||
message(WARNING "No PROJECT_ARCH value specified, using ${PROJECT_ARCH}")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
||||||
@@ -92,6 +91,7 @@ if(OS_LINUX)
|
|||||||
-Wno-unused-parameter # Don't warn about unused parameters
|
-Wno-unused-parameter # Don't warn about unused parameters
|
||||||
-Wno-error=comment # Don't warn about code in comments
|
-Wno-error=comment # Don't warn about code in comments
|
||||||
-Wno-comment # Don't warn about code in comments
|
-Wno-comment # Don't warn about code in comments
|
||||||
|
-Wno-deprecated-declarations # Don't warn about using deprecated methods
|
||||||
)
|
)
|
||||||
list(APPEND CEF_C_COMPILER_FLAGS
|
list(APPEND CEF_C_COMPILER_FLAGS
|
||||||
-std=c99 # Use the C99 language standard
|
-std=c99 # Use the C99 language standard
|
||||||
@@ -101,7 +101,7 @@ if(OS_LINUX)
|
|||||||
-fno-rtti # Disable real-time type information
|
-fno-rtti # Disable real-time type information
|
||||||
-fno-threadsafe-statics # Don't generate thread-safe statics
|
-fno-threadsafe-statics # Don't generate thread-safe statics
|
||||||
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
||||||
-std=gnu++11 # Use the C++11 language standard including GNU extensions
|
-std=c++17 # Use the C++17 language standard
|
||||||
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
||||||
)
|
)
|
||||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||||
@@ -218,19 +218,18 @@ if(OS_LINUX)
|
|||||||
libcef.so
|
libcef.so
|
||||||
libEGL.so
|
libEGL.so
|
||||||
libGLESv2.so
|
libGLESv2.so
|
||||||
natives_blob.bin
|
libvk_swiftshader.so
|
||||||
|
libvulkan.so.1
|
||||||
snapshot_blob.bin
|
snapshot_blob.bin
|
||||||
v8_context_snapshot.bin
|
v8_context_snapshot.bin
|
||||||
swiftshader
|
vk_swiftshader_icd.json
|
||||||
)
|
)
|
||||||
|
|
||||||
# List of CEF resource files.
|
# List of CEF resource files.
|
||||||
set(CEF_RESOURCE_FILES
|
set(CEF_RESOURCE_FILES
|
||||||
cef.pak
|
chrome_100_percent.pak
|
||||||
cef_100_percent.pak
|
chrome_200_percent.pak
|
||||||
cef_200_percent.pak
|
resources.pak
|
||||||
cef_extensions.pak
|
|
||||||
devtools_resources.pak
|
|
||||||
icudtl.dat
|
icudtl.dat
|
||||||
locales
|
locales
|
||||||
)
|
)
|
||||||
@@ -247,7 +246,7 @@ endif()
|
|||||||
# Mac OS X configuration.
|
# Mac OS X configuration.
|
||||||
#
|
#
|
||||||
|
|
||||||
if(OS_MACOSX)
|
if(OS_MAC)
|
||||||
# Platform-specific compiler/linker flags.
|
# Platform-specific compiler/linker flags.
|
||||||
# See also Xcode target properties in cef_macros.cmake.
|
# See also Xcode target properties in cef_macros.cmake.
|
||||||
set(CEF_LIBTYPE SHARED)
|
set(CEF_LIBTYPE SHARED)
|
||||||
@@ -273,7 +272,7 @@ if(OS_MACOSX)
|
|||||||
-fno-threadsafe-statics # Don't generate thread-safe statics
|
-fno-threadsafe-statics # Don't generate thread-safe statics
|
||||||
-fobjc-call-cxx-cdtors # Call the constructor/destructor of C++ instance variables in ObjC objects
|
-fobjc-call-cxx-cdtors # Call the constructor/destructor of C++ instance variables in ObjC objects
|
||||||
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
||||||
-std=gnu++11 # Use the C++11 language standard including GNU extensions
|
-std=c++17 # Use the C++17 language standard
|
||||||
-Wno-narrowing # Don't warn about type narrowing
|
-Wno-narrowing # Don't warn about type narrowing
|
||||||
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
||||||
)
|
)
|
||||||
@@ -305,13 +304,14 @@ if(OS_MACOSX)
|
|||||||
# Standard libraries.
|
# Standard libraries.
|
||||||
set(CEF_STANDARD_LIBS
|
set(CEF_STANDARD_LIBS
|
||||||
-lpthread
|
-lpthread
|
||||||
"-framework Cocoa"
|
|
||||||
"-framework AppKit"
|
"-framework AppKit"
|
||||||
|
"-framework Cocoa"
|
||||||
|
"-framework IOSurface"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Find the newest available base SDK.
|
# Find the newest available base SDK.
|
||||||
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
foreach(OS_VERSION 10.11 10.10 10.9)
|
foreach(OS_VERSION 14.2 14.0 11.0)
|
||||||
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk")
|
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk")
|
||||||
if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
|
if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
|
||||||
set(CMAKE_OSX_SYSROOT ${SDK})
|
set(CMAKE_OSX_SYSROOT ${SDK})
|
||||||
@@ -319,7 +319,7 @@ if(OS_MACOSX)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Target SDK.
|
# Target SDK.
|
||||||
set(CEF_TARGET_SDK "10.9")
|
set(CEF_TARGET_SDK "11.0")
|
||||||
list(APPEND CEF_COMPILER_FLAGS
|
list(APPEND CEF_COMPILER_FLAGS
|
||||||
-mmacosx-version-min=${CEF_TARGET_SDK}
|
-mmacosx-version-min=${CEF_TARGET_SDK}
|
||||||
)
|
)
|
||||||
@@ -328,10 +328,15 @@ if(OS_MACOSX)
|
|||||||
# Target architecture.
|
# Target architecture.
|
||||||
if(PROJECT_ARCH STREQUAL "x86_64")
|
if(PROJECT_ARCH STREQUAL "x86_64")
|
||||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||||
|
elseif(PROJECT_ARCH STREQUAL "arm64")
|
||||||
|
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_OSX_ARCHITECTURES "i386")
|
set(CMAKE_OSX_ARCHITECTURES "i386")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Prevent Xcode 11 from doing automatic codesigning.
|
||||||
|
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
|
||||||
|
|
||||||
# CEF directory paths.
|
# CEF directory paths.
|
||||||
set(CEF_BINARY_DIR "${_CEF_ROOT}/$<CONFIGURATION>")
|
set(CEF_BINARY_DIR "${_CEF_ROOT}/$<CONFIGURATION>")
|
||||||
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
|
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
|
||||||
@@ -342,10 +347,24 @@ if(OS_MACOSX)
|
|||||||
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
||||||
)
|
)
|
||||||
|
|
||||||
|
list(APPEND CEF_STANDARD_LIBS
|
||||||
|
-lsandbox
|
||||||
|
)
|
||||||
|
|
||||||
# CEF sandbox library paths.
|
# CEF sandbox library paths.
|
||||||
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.a")
|
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.a")
|
||||||
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.a")
|
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.a")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# CEF Helper app suffixes.
|
||||||
|
# Format is "<name suffix>:<target suffix>:<plist suffix>".
|
||||||
|
set(CEF_HELPER_APP_SUFFIXES
|
||||||
|
"::"
|
||||||
|
" (Alerts):_alerts:.alerts"
|
||||||
|
" (GPU):_gpu:.gpu"
|
||||||
|
" (Plugin):_plugin:.plugin"
|
||||||
|
" (Renderer):_renderer:.renderer"
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@@ -364,19 +383,8 @@ if(OS_WINDOWS)
|
|||||||
|
|
||||||
if(USE_SANDBOX)
|
if(USE_SANDBOX)
|
||||||
# Check if the current MSVC version is compatible with the cef_sandbox.lib
|
# Check if the current MSVC version is compatible with the cef_sandbox.lib
|
||||||
# static library. For a list of all version numbers see
|
# static library. We require VS2015 or newer.
|
||||||
# https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering
|
if(MSVC_VERSION LESS 1900)
|
||||||
list(APPEND supported_msvc_versions
|
|
||||||
1900 # VS2015 and updates 1, 2, & 3
|
|
||||||
1910 # VS2017 version 15.1 & 15.2
|
|
||||||
1911 # VS2017 version 15.3 & 15.4
|
|
||||||
1912 # VS2017 version 15.5
|
|
||||||
1913 # VS2017 version 15.6
|
|
||||||
1914 # VS2017 version 15.7
|
|
||||||
1915 # VS2017 version 15.8
|
|
||||||
)
|
|
||||||
list(FIND supported_msvc_versions ${MSVC_VERSION} _index)
|
|
||||||
if (${_index} EQUAL -1)
|
|
||||||
message(WARNING "CEF sandbox is not compatible with the current MSVC version (${MSVC_VERSION})")
|
message(WARNING "CEF sandbox is not compatible with the current MSVC version (${MSVC_VERSION})")
|
||||||
set(USE_SANDBOX OFF)
|
set(USE_SANDBOX OFF)
|
||||||
endif()
|
endif()
|
||||||
@@ -403,6 +411,7 @@ if(OS_WINDOWS)
|
|||||||
/wd4100 # Ignore "unreferenced formal parameter" warning
|
/wd4100 # Ignore "unreferenced formal parameter" warning
|
||||||
/wd4127 # Ignore "conditional expression is constant" warning
|
/wd4127 # Ignore "conditional expression is constant" warning
|
||||||
/wd4244 # Ignore "conversion possible loss of data" warning
|
/wd4244 # Ignore "conversion possible loss of data" warning
|
||||||
|
/wd4324 # Ignore "structure was padded due to alignment specifier" warning
|
||||||
/wd4481 # Ignore "nonstandard extension used: override" warning
|
/wd4481 # Ignore "nonstandard extension used: override" warning
|
||||||
/wd4512 # Ignore "assignment operator could not be generated" warning
|
/wd4512 # Ignore "assignment operator could not be generated" warning
|
||||||
/wd4701 # Ignore "potentially uninitialized local variable" warning
|
/wd4701 # Ignore "potentially uninitialized local variable" warning
|
||||||
@@ -419,17 +428,75 @@ if(OS_WINDOWS)
|
|||||||
/Ob2 # Inline any suitable function
|
/Ob2 # Inline any suitable function
|
||||||
/GF # Enable string pooling
|
/GF # Enable string pooling
|
||||||
)
|
)
|
||||||
|
list(APPEND CEF_CXX_COMPILER_FLAGS
|
||||||
|
/std:c++17 # Use the C++17 language standard
|
||||||
|
)
|
||||||
list(APPEND CEF_LINKER_FLAGS_DEBUG
|
list(APPEND CEF_LINKER_FLAGS_DEBUG
|
||||||
/DEBUG # Generate debug information
|
/DEBUG # Generate debug information
|
||||||
)
|
)
|
||||||
list(APPEND CEF_EXE_LINKER_FLAGS
|
list(APPEND CEF_EXE_LINKER_FLAGS
|
||||||
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
|
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
|
||||||
/LARGEADDRESSAWARE # Allow 32-bit processes to access 3GB of RAM
|
/LARGEADDRESSAWARE # Allow 32-bit processes to access 3GB of RAM
|
||||||
|
|
||||||
|
# Delayload most libraries as the dlls are simply not required at startup (or
|
||||||
|
# at all, depending on the process type). Some dlls open handles when they are
|
||||||
|
# loaded, and we may not want them to be loaded in renderers or other sandboxed
|
||||||
|
# processes. Conversely, some dlls must be loaded before sandbox lockdown. In
|
||||||
|
# unsandboxed processes they will load when first needed. The linker will
|
||||||
|
# automatically ignore anything which is not linked to the binary at all (it is
|
||||||
|
# harmless to have an unmatched /delayload). This list should be kept in sync
|
||||||
|
# with Chromium's "delayloads" target from the //build/config/win/BUILD.gn file.
|
||||||
|
/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll
|
||||||
|
/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll
|
||||||
|
/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll
|
||||||
|
/DELAYLOAD:advapi32.dll
|
||||||
|
/DELAYLOAD:comctl32.dll
|
||||||
|
/DELAYLOAD:comdlg32.dll
|
||||||
|
/DELAYLOAD:credui.dll
|
||||||
|
/DELAYLOAD:cryptui.dll
|
||||||
|
/DELAYLOAD:d3d11.dll
|
||||||
|
/DELAYLOAD:d3d9.dll
|
||||||
|
/DELAYLOAD:dwmapi.dll
|
||||||
|
/DELAYLOAD:dxgi.dll
|
||||||
|
/DELAYLOAD:dxva2.dll
|
||||||
|
/DELAYLOAD:esent.dll
|
||||||
|
/DELAYLOAD:gdi32.dll
|
||||||
|
/DELAYLOAD:hid.dll
|
||||||
|
/DELAYLOAD:imagehlp.dll
|
||||||
|
/DELAYLOAD:imm32.dll
|
||||||
|
/DELAYLOAD:msi.dll
|
||||||
|
/DELAYLOAD:netapi32.dll
|
||||||
|
/DELAYLOAD:ncrypt.dll
|
||||||
|
/DELAYLOAD:ole32.dll
|
||||||
|
/DELAYLOAD:oleacc.dll
|
||||||
|
/DELAYLOAD:propsys.dll
|
||||||
|
/DELAYLOAD:psapi.dll
|
||||||
|
/DELAYLOAD:rpcrt4.dll
|
||||||
|
/DELAYLOAD:rstrtmgr.dll
|
||||||
|
/DELAYLOAD:setupapi.dll
|
||||||
|
/DELAYLOAD:shell32.dll
|
||||||
|
/DELAYLOAD:shlwapi.dll
|
||||||
|
/DELAYLOAD:uiautomationcore.dll
|
||||||
|
/DELAYLOAD:urlmon.dll
|
||||||
|
/DELAYLOAD:user32.dll
|
||||||
|
/DELAYLOAD:usp10.dll
|
||||||
|
/DELAYLOAD:uxtheme.dll
|
||||||
|
/DELAYLOAD:wer.dll
|
||||||
|
/DELAYLOAD:wevtapi.dll
|
||||||
|
/DELAYLOAD:wininet.dll
|
||||||
|
/DELAYLOAD:winusb.dll
|
||||||
|
/DELAYLOAD:wsock32.dll
|
||||||
|
/DELAYLOAD:wtsapi32.dll
|
||||||
)
|
)
|
||||||
list(APPEND CEF_COMPILER_DEFINES
|
list(APPEND CEF_COMPILER_DEFINES
|
||||||
WIN32 _WIN32 _WINDOWS # Windows platform
|
WIN32 _WIN32 _WINDOWS # Windows platform
|
||||||
UNICODE _UNICODE # Unicode build
|
UNICODE _UNICODE # Unicode build
|
||||||
WINVER=0x0601 _WIN32_WINNT=0x601 # Targeting Windows 7
|
# Targeting Windows 10. We can't say `=_WIN32_WINNT_WIN10` here because
|
||||||
|
# some files do `#if WINVER < 0x0600` without including windows.h before,
|
||||||
|
# and then _WIN32_WINNT_WIN10 isn't yet known to be 0x0A00.
|
||||||
|
WINVER=0x0A00
|
||||||
|
_WIN32_WINNT=0x0A00
|
||||||
|
NTDDI_VERSION=NTDDI_WIN10_FE
|
||||||
NOMINMAX # Use the standard's templated min/max
|
NOMINMAX # Use the standard's templated min/max
|
||||||
WIN32_LEAN_AND_MEAN # Exclude less common API declarations
|
WIN32_LEAN_AND_MEAN # Exclude less common API declarations
|
||||||
_HAS_EXCEPTIONS=0 # Disable exceptions
|
_HAS_EXCEPTIONS=0 # Disable exceptions
|
||||||
@@ -438,9 +505,27 @@ if(OS_WINDOWS)
|
|||||||
NDEBUG _NDEBUG # Not a debug build
|
NDEBUG _NDEBUG # Not a debug build
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(PROJECT_ARCH STREQUAL "x86")
|
||||||
|
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB minimum
|
||||||
|
# needed by CEF's main thread. This saves significant memory on threads
|
||||||
|
# (like those in the Windows thread pool, and others) whose stack size we
|
||||||
|
# can only control through this setting. The main thread (in 32-bit builds
|
||||||
|
# only) uses fibers to switch to a 4MiB stack at runtime via
|
||||||
|
# CefRunWinMainWithPreferredStackSize().
|
||||||
|
list(APPEND CEF_EXE_LINKER_FLAGS
|
||||||
|
/STACK:0x80000
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# Increase the initial stack size to 8MiB from the default 1MiB.
|
||||||
|
list(APPEND CEF_EXE_LINKER_FLAGS
|
||||||
|
/STACK:0x800000
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Standard libraries.
|
# Standard libraries.
|
||||||
set(CEF_STANDARD_LIBS
|
set(CEF_STANDARD_LIBS
|
||||||
comctl32.lib
|
comctl32.lib
|
||||||
|
gdi32.lib
|
||||||
rpcrt4.lib
|
rpcrt4.lib
|
||||||
shlwapi.lib
|
shlwapi.lib
|
||||||
ws2_32.lib
|
ws2_32.lib
|
||||||
@@ -459,24 +544,29 @@ if(OS_WINDOWS)
|
|||||||
# List of CEF binary files.
|
# List of CEF binary files.
|
||||||
set(CEF_BINARY_FILES
|
set(CEF_BINARY_FILES
|
||||||
chrome_elf.dll
|
chrome_elf.dll
|
||||||
d3dcompiler_43.dll
|
|
||||||
d3dcompiler_47.dll
|
d3dcompiler_47.dll
|
||||||
libcef.dll
|
libcef.dll
|
||||||
libEGL.dll
|
libEGL.dll
|
||||||
libGLESv2.dll
|
libGLESv2.dll
|
||||||
natives_blob.bin
|
|
||||||
snapshot_blob.bin
|
snapshot_blob.bin
|
||||||
v8_context_snapshot.bin
|
v8_context_snapshot.bin
|
||||||
swiftshader
|
vk_swiftshader.dll
|
||||||
|
vk_swiftshader_icd.json
|
||||||
|
vulkan-1.dll
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(PROJECT_ARCH STREQUAL "x86_64")
|
||||||
|
list(APPEND CEF_BINARY_FILES
|
||||||
|
dxil.dll
|
||||||
|
dxcompiler.dll
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# List of CEF resource files.
|
# List of CEF resource files.
|
||||||
set(CEF_RESOURCE_FILES
|
set(CEF_RESOURCE_FILES
|
||||||
cef.pak
|
chrome_100_percent.pak
|
||||||
cef_100_percent.pak
|
chrome_200_percent.pak
|
||||||
cef_200_percent.pak
|
resources.pak
|
||||||
cef_extensions.pak
|
|
||||||
devtools_resources.pak
|
|
||||||
icudtl.dat
|
icudtl.dat
|
||||||
locales
|
locales
|
||||||
)
|
)
|
||||||
@@ -486,13 +576,27 @@ if(OS_WINDOWS)
|
|||||||
PSAPI_VERSION=1 # Required by cef_sandbox.lib
|
PSAPI_VERSION=1 # Required by cef_sandbox.lib
|
||||||
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
||||||
)
|
)
|
||||||
|
list(APPEND CEF_COMPILER_DEFINES_DEBUG
|
||||||
|
_HAS_ITERATOR_DEBUGGING=0 # Disable iterator debugging
|
||||||
|
)
|
||||||
|
|
||||||
# Libraries required by cef_sandbox.lib.
|
# Libraries required by cef_sandbox.lib.
|
||||||
set(CEF_SANDBOX_STANDARD_LIBS
|
set(CEF_SANDBOX_STANDARD_LIBS
|
||||||
|
Advapi32.lib
|
||||||
dbghelp.lib
|
dbghelp.lib
|
||||||
|
Delayimp.lib
|
||||||
|
ntdll.lib
|
||||||
|
OleAut32.lib
|
||||||
|
PowrProf.lib
|
||||||
|
Propsys.lib
|
||||||
psapi.lib
|
psapi.lib
|
||||||
|
SetupAPI.lib
|
||||||
|
Shell32.lib
|
||||||
|
Shcore.lib
|
||||||
|
Userenv.lib
|
||||||
version.lib
|
version.lib
|
||||||
wbemuuid.lib
|
wbemuuid.lib
|
||||||
|
WindowsApp.lib
|
||||||
winmm.lib
|
winmm.lib
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
97
include/base/cef_atomic_flag.h
Normal file
97
include/base/cef_atomic_flag.h
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||||
|
// Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/synchronization/atomic_flag.h"
|
||||||
|
|
||||||
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
|
// The following is substantially similar to the Chromium implementation.
|
||||||
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
|
// updated to match.
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#include "include/base/cef_thread_checker.h"
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A flag that can safely be set from one thread and read from other threads.
|
||||||
|
///
|
||||||
|
/// This class IS NOT intended for synchronization between threads.
|
||||||
|
///
|
||||||
|
class AtomicFlag {
|
||||||
|
public:
|
||||||
|
AtomicFlag();
|
||||||
|
|
||||||
|
AtomicFlag(const AtomicFlag&) = delete;
|
||||||
|
AtomicFlag& operator=(const AtomicFlag&) = delete;
|
||||||
|
|
||||||
|
~AtomicFlag();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Set the flag. Must always be called from the same thread.
|
||||||
|
///
|
||||||
|
void Set();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns true iff the flag was set. If this returns true, the current
|
||||||
|
/// thread is guaranteed to be synchronized with all memory operations on the
|
||||||
|
/// thread which invoked Set() up until at least the first call to Set() on
|
||||||
|
/// it.
|
||||||
|
///
|
||||||
|
bool IsSet() const {
|
||||||
|
// Inline here: this has a measurable performance impact on base::WeakPtr.
|
||||||
|
return flag_.load(std::memory_order_acquire) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Resets the flag. Be careful when using this: callers might not expect
|
||||||
|
/// IsSet() to return false after returning true once.
|
||||||
|
///
|
||||||
|
void UnsafeResetForTesting();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::atomic<uint_fast8_t> flag_{0};
|
||||||
|
base::ThreadChecker set_thread_checker_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_FLAG_H_
|
||||||
@@ -43,120 +43,78 @@
|
|||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/atomic_ref_count.h"
|
#include "base/atomic_ref_count.h"
|
||||||
|
|
||||||
// Used when declaring a base::AtomicRefCount value. This is an object type with
|
|
||||||
// Chromium headers.
|
|
||||||
#define ATOMIC_DECLARATION (0)
|
|
||||||
|
|
||||||
// Maintaining compatibility with AtompicRefCount* functions that were removed
|
|
||||||
// from Chromium in http://crrev.com/ee96d561.
|
|
||||||
namespace base {
|
|
||||||
|
|
||||||
// Increment a reference count by 1.
|
|
||||||
inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) {
|
|
||||||
const_cast<AtomicRefCount*>(ptr)->Increment();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decrement a reference count by 1 and return whether the result is non-zero.
|
|
||||||
// Insert barriers to ensure that state written before the reference count
|
|
||||||
// became zero will be visible to a thread that has just made the count zero.
|
|
||||||
inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) {
|
|
||||||
return const_cast<AtomicRefCount*>(ptr)->Decrement();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return whether the reference count is one. If the reference count is used
|
|
||||||
// in the conventional way, a refrerence count of 1 implies that the current
|
|
||||||
// thread owns the reference and no other thread shares it. This call performs
|
|
||||||
// the test for a reference count of one, and performs the memory barrier
|
|
||||||
// needed for the owning thread to act on the object, knowing that it has
|
|
||||||
// exclusive access to the object.
|
|
||||||
inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) {
|
|
||||||
return const_cast<AtomicRefCount*>(ptr)->IsOne();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return whether the reference count is zero. With conventional object
|
|
||||||
// referencing counting, the object will be destroyed, so the reference count
|
|
||||||
// should never be zero. Hence this is generally used for a debug check.
|
|
||||||
inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) {
|
|
||||||
return const_cast<AtomicRefCount*>(ptr)->IsZero();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include "include/base/cef_atomicops.h"
|
#include <atomic>
|
||||||
|
|
||||||
// Annotations are not currently supported.
|
|
||||||
#define ANNOTATE_HAPPENS_BEFORE(obj) /* empty */
|
|
||||||
#define ANNOTATE_HAPPENS_AFTER(obj) /* empty */
|
|
||||||
|
|
||||||
// Used when declaring a base::AtomicRefCount value. This is an integer/ptr type
|
|
||||||
// with CEF headers.
|
|
||||||
#define ATOMIC_DECLARATION = 0
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
typedef subtle::Atomic32 AtomicRefCount;
|
class AtomicRefCount {
|
||||||
|
public:
|
||||||
|
constexpr AtomicRefCount() : ref_count_(0) {}
|
||||||
|
explicit constexpr AtomicRefCount(int initial_value)
|
||||||
|
: ref_count_(initial_value) {}
|
||||||
|
|
||||||
// Increment a reference count by "increment", which must exceed 0.
|
///
|
||||||
inline void AtomicRefCountIncN(volatile AtomicRefCount* ptr,
|
/// Increment a reference count.
|
||||||
AtomicRefCount increment) {
|
/// Returns the previous value of the count.
|
||||||
subtle::NoBarrier_AtomicIncrement(ptr, increment);
|
///
|
||||||
}
|
int Increment() { return Increment(1); }
|
||||||
|
|
||||||
// Decrement a reference count by "decrement", which must exceed 0,
|
///
|
||||||
// and return whether the result is non-zero.
|
/// Increment a reference count by "increment", which must exceed 0.
|
||||||
// Insert barriers to ensure that state written before the reference count
|
/// Returns the previous value of the count.
|
||||||
// became zero will be visible to a thread that has just made the count zero.
|
///
|
||||||
inline bool AtomicRefCountDecN(volatile AtomicRefCount* ptr,
|
int Increment(int increment) {
|
||||||
AtomicRefCount decrement) {
|
return ref_count_.fetch_add(increment, std::memory_order_relaxed);
|
||||||
ANNOTATE_HAPPENS_BEFORE(ptr);
|
|
||||||
bool res = (subtle::Barrier_AtomicIncrement(ptr, -decrement) != 0);
|
|
||||||
if (!res) {
|
|
||||||
ANNOTATE_HAPPENS_AFTER(ptr);
|
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increment a reference count by 1.
|
///
|
||||||
inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) {
|
/// Decrement a reference count, and return whether the result is non-zero.
|
||||||
base::AtomicRefCountIncN(ptr, 1);
|
/// Insert barriers to ensure that state written before the reference count
|
||||||
}
|
/// became zero will be visible to a thread that has just made the count zero.
|
||||||
|
///
|
||||||
// Decrement a reference count by 1 and return whether the result is non-zero.
|
bool Decrement() {
|
||||||
// Insert barriers to ensure that state written before the reference count
|
// TODO(jbroman): Technically this doesn't need to be an acquire operation
|
||||||
// became zero will be visible to a thread that has just made the count zero.
|
// unless the result is 1 (i.e., the ref count did indeed reach zero).
|
||||||
inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) {
|
// However, there are toolchain issues that make that not work as well at
|
||||||
return base::AtomicRefCountDecN(ptr, 1);
|
// present (notably TSAN doesn't like it).
|
||||||
}
|
return ref_count_.fetch_sub(1, std::memory_order_acq_rel) != 1;
|
||||||
|
|
||||||
// Return whether the reference count is one. If the reference count is used
|
|
||||||
// in the conventional way, a refrerence count of 1 implies that the current
|
|
||||||
// thread owns the reference and no other thread shares it. This call performs
|
|
||||||
// the test for a reference count of one, and performs the memory barrier
|
|
||||||
// needed for the owning thread to act on the object, knowing that it has
|
|
||||||
// exclusive access to the object.
|
|
||||||
inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) {
|
|
||||||
bool res = (subtle::Acquire_Load(ptr) == 1);
|
|
||||||
if (res) {
|
|
||||||
ANNOTATE_HAPPENS_AFTER(ptr);
|
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return whether the reference count is zero. With conventional object
|
///
|
||||||
// referencing counting, the object will be destroyed, so the reference count
|
/// Return whether the reference count is one. If the reference count is used
|
||||||
// should never be zero. Hence this is generally used for a debug check.
|
/// in the conventional way, a refrerence count of 1 implies that the current
|
||||||
inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) {
|
/// thread owns the reference and no other thread shares it. This call
|
||||||
bool res = (subtle::Acquire_Load(ptr) == 0);
|
/// performs the test for a reference count of one, and performs the memory
|
||||||
if (res) {
|
/// barrier needed for the owning thread to act on the object, knowing that it
|
||||||
ANNOTATE_HAPPENS_AFTER(ptr);
|
/// has exclusive access to the object.
|
||||||
|
///
|
||||||
|
bool IsOne() const { return ref_count_.load(std::memory_order_acquire) == 1; }
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return whether the reference count is zero. With conventional object
|
||||||
|
/// referencing counting, the object will be destroyed, so the reference count
|
||||||
|
/// should never be zero. Hence this is generally used for a debug check.
|
||||||
|
///
|
||||||
|
bool IsZero() const {
|
||||||
|
return ref_count_.load(std::memory_order_acquire) == 0;
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
}
|
///
|
||||||
|
/// Returns the current reference count (with no barriers). This is subtle,
|
||||||
|
/// and should be used only for debugging.
|
||||||
|
///
|
||||||
|
int SubtleRefCountForDebug() const {
|
||||||
|
return ref_count_.load(std::memory_order_relaxed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::atomic_int ref_count_;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
@@ -1,199 +0,0 @@
|
|||||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
|
||||||
// Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// For atomic operations on reference counts, see cef_atomic_ref_count.h.
|
|
||||||
|
|
||||||
// The routines exported by this module are subtle. If you use them, even if
|
|
||||||
// you get the code right, it will depend on careful reasoning about atomicity
|
|
||||||
// and memory ordering; it will be less readable, and harder to maintain. If
|
|
||||||
// you plan to use these routines, you should have a good reason, such as solid
|
|
||||||
// evidence that performance would otherwise suffer, or there being no
|
|
||||||
// alternative. You should assume only properties explicitly guaranteed by the
|
|
||||||
// specifications in this file. You are almost certainly _not_ writing code
|
|
||||||
// just for the x86; if you assume x86 semantics, x86 hardware bugs and
|
|
||||||
// implementations on other archtectures will cause your code to break. If you
|
|
||||||
// do not know what you are doing, avoid these routines, and use a Mutex.
|
|
||||||
//
|
|
||||||
// It is incorrect to make direct assignments to/from an atomic variable.
|
|
||||||
// You should use one of the Load or Store routines. The NoBarrier
|
|
||||||
// versions are provided when no barriers are needed:
|
|
||||||
// NoBarrier_Store()
|
|
||||||
// NoBarrier_Load()
|
|
||||||
// Although there are currently no compiler enforcement, you are encouraged
|
|
||||||
// to use these.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_ATOMICOPS_H_
|
|
||||||
#define CEF_INCLUDE_BASE_CEF_ATOMICOPS_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(BASE_ATOMICOPS_H_)
|
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
|
||||||
#include "base/atomicops.h"
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
|
||||||
// The following is substantially similar to the Chromium implementation.
|
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
|
||||||
// updated to match.
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "include/base/cef_build.h"
|
|
||||||
|
|
||||||
#if defined(OS_WIN) && defined(ARCH_CPU_64_BITS)
|
|
||||||
// windows.h #defines this (only on x64). This causes problems because the
|
|
||||||
// public API also uses MemoryBarrier at the public name for this fence. So, on
|
|
||||||
// X64, undef it, and call its documented
|
|
||||||
// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx)
|
|
||||||
// implementation directly.
|
|
||||||
#undef MemoryBarrier
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
namespace subtle {
|
|
||||||
|
|
||||||
typedef int32_t Atomic32;
|
|
||||||
#ifdef ARCH_CPU_64_BITS
|
|
||||||
// We need to be able to go between Atomic64 and AtomicWord implicitly. This
|
|
||||||
// means Atomic64 and AtomicWord should be the same type on 64-bit.
|
|
||||||
#if defined(__ILP32__) || defined(OS_NACL)
|
|
||||||
// NaCl's intptr_t is not actually 64-bits on 64-bit!
|
|
||||||
// http://code.google.com/p/nativeclient/issues/detail?id=1162
|
|
||||||
typedef int64_t Atomic64;
|
|
||||||
#else
|
|
||||||
typedef intptr_t Atomic64;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or
|
|
||||||
// Atomic64 routines below, depending on your architecture.
|
|
||||||
typedef intptr_t AtomicWord;
|
|
||||||
|
|
||||||
// Atomically execute:
|
|
||||||
// result = *ptr;
|
|
||||||
// if (*ptr == old_value)
|
|
||||||
// *ptr = new_value;
|
|
||||||
// return result;
|
|
||||||
//
|
|
||||||
// I.e., replace "*ptr" with "new_value" if "*ptr" used to be "old_value".
|
|
||||||
// Always return the old value of "*ptr"
|
|
||||||
//
|
|
||||||
// This routine implies no memory barriers.
|
|
||||||
Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value);
|
|
||||||
|
|
||||||
// Atomically store new_value into *ptr, returning the previous value held in
|
|
||||||
// *ptr. This routine implies no memory barriers.
|
|
||||||
Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value);
|
|
||||||
|
|
||||||
// Atomically increment *ptr by "increment". Returns the new value of
|
|
||||||
// *ptr with the increment applied. This routine implies no memory barriers.
|
|
||||||
Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment);
|
|
||||||
|
|
||||||
Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment);
|
|
||||||
|
|
||||||
// These following lower-level operations are typically useful only to people
|
|
||||||
// implementing higher-level synchronization operations like spinlocks,
|
|
||||||
// mutexes, and condition-variables. They combine CompareAndSwap(), a load, or
|
|
||||||
// a store with appropriate memory-ordering instructions. "Acquire" operations
|
|
||||||
// ensure that no later memory access can be reordered ahead of the operation.
|
|
||||||
// "Release" operations ensure that no previous memory access can be reordered
|
|
||||||
// after the operation. "Barrier" operations have both "Acquire" and "Release"
|
|
||||||
// semantics. A MemoryBarrier() has "Barrier" semantics, but does no memory
|
|
||||||
// access.
|
|
||||||
Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value);
|
|
||||||
Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value);
|
|
||||||
|
|
||||||
void MemoryBarrier();
|
|
||||||
void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value);
|
|
||||||
void Acquire_Store(volatile Atomic32* ptr, Atomic32 value);
|
|
||||||
void Release_Store(volatile Atomic32* ptr, Atomic32 value);
|
|
||||||
|
|
||||||
Atomic32 NoBarrier_Load(volatile const Atomic32* ptr);
|
|
||||||
Atomic32 Acquire_Load(volatile const Atomic32* ptr);
|
|
||||||
Atomic32 Release_Load(volatile const Atomic32* ptr);
|
|
||||||
|
|
||||||
// 64-bit atomic operations (only available on 64-bit processors).
|
|
||||||
#ifdef ARCH_CPU_64_BITS
|
|
||||||
Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value);
|
|
||||||
Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value);
|
|
||||||
Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment);
|
|
||||||
Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment);
|
|
||||||
|
|
||||||
Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value);
|
|
||||||
Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value);
|
|
||||||
void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value);
|
|
||||||
void Acquire_Store(volatile Atomic64* ptr, Atomic64 value);
|
|
||||||
void Release_Store(volatile Atomic64* ptr, Atomic64 value);
|
|
||||||
Atomic64 NoBarrier_Load(volatile const Atomic64* ptr);
|
|
||||||
Atomic64 Acquire_Load(volatile const Atomic64* ptr);
|
|
||||||
Atomic64 Release_Load(volatile const Atomic64* ptr);
|
|
||||||
#endif // ARCH_CPU_64_BITS
|
|
||||||
|
|
||||||
} // namespace subtle
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
// Include our platform specific implementation.
|
|
||||||
#if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY)
|
|
||||||
#include "include/base/internal/cef_atomicops_x86_msvc.h"
|
|
||||||
#elif defined(OS_MACOSX)
|
|
||||||
#include "include/base/internal/cef_atomicops_mac.h"
|
|
||||||
#elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY)
|
|
||||||
#include "include/base/internal/cef_atomicops_x86_gcc.h"
|
|
||||||
#elif defined(COMPILER_GCC) && defined(__ARM_ARCH)
|
|
||||||
#include "include/base/internal/cef_atomicops_arm_gcc.h"
|
|
||||||
#else
|
|
||||||
#error "Atomic operations are not supported on your platform"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// On some platforms we need additional declarations to make
|
|
||||||
// AtomicWord compatible with our other Atomic* types.
|
|
||||||
#if defined(OS_MACOSX) || defined(OS_OPENBSD)
|
|
||||||
#include "include/base/internal/cef_atomicops_atomicword_compat.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_ATOMICOPS_H_
|
|
||||||
90
include/base/cef_auto_reset.h
Normal file
90
include/base/cef_auto_reset.h
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||||
|
// Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
// base::AutoReset<> is useful for setting a variable to a new value only within
|
||||||
|
// a particular scope. An base::AutoReset<> object resets a variable to its
|
||||||
|
// original value upon destruction, making it an alternative to writing
|
||||||
|
// "var = false;" or "var = old_val;" at all of a block's exit points.
|
||||||
|
//
|
||||||
|
// This should be obvious, but note that an base::AutoReset<> instance should
|
||||||
|
// have a shorter lifetime than its scoped_variable, to prevent invalid memory
|
||||||
|
// writes when the base::AutoReset<> object is destroyed.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_AUTO_RESET_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_AUTO_RESET_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/auto_reset.h"
|
||||||
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
|
// The following is substantially similar to the Chromium implementation.
|
||||||
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
|
// updated to match.
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class AutoReset {
|
||||||
|
public:
|
||||||
|
template <typename U>
|
||||||
|
AutoReset(T* scoped_variable, U&& new_value)
|
||||||
|
: scoped_variable_(scoped_variable),
|
||||||
|
original_value_(
|
||||||
|
std::exchange(*scoped_variable_, std::forward<U>(new_value))) {}
|
||||||
|
|
||||||
|
AutoReset(AutoReset&& other)
|
||||||
|
: scoped_variable_(std::exchange(other.scoped_variable_, nullptr)),
|
||||||
|
original_value_(std::move(other.original_value_)) {}
|
||||||
|
|
||||||
|
AutoReset& operator=(AutoReset&& rhs) {
|
||||||
|
scoped_variable_ = std::exchange(rhs.scoped_variable_, nullptr);
|
||||||
|
original_value_ = std::move(rhs.original_value_);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~AutoReset() {
|
||||||
|
if (scoped_variable_) {
|
||||||
|
*scoped_variable_ = std::move(original_value_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
T* scoped_variable_;
|
||||||
|
T original_value_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_AUTO_RESET_H_
|
||||||
@@ -28,546 +28,361 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
///
|
||||||
|
/// \file
|
||||||
|
/// base::BindOnce() and base::BindRepeating() are helpers for creating
|
||||||
|
/// base::OnceCallback and base::RepeatingCallback objects respectively.
|
||||||
|
///
|
||||||
|
/// For a runnable object of n-arity, the base::Bind*() family allows partial
|
||||||
|
/// application of the first m arguments. The remaining n - m arguments must be
|
||||||
|
/// passed when invoking the callback with Run().
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// // The first argument is bound at callback creation; the remaining
|
||||||
|
/// // two must be passed when calling Run() on the callback object.
|
||||||
|
/// base::OnceCallback<long(int, long)> cb = base::BindOnce(
|
||||||
|
/// [](short x, int y, long z) { return x * y * z; }, 42);
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// When binding to a method, the receiver object must also be specified at
|
||||||
|
/// callback creation time. When Run() is invoked, the method will be invoked on
|
||||||
|
/// the specified receiver object.
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// class C : public base::RefCounted<C> { void F(); };
|
||||||
|
/// auto instance = base::MakeRefCounted<C>();
|
||||||
|
/// auto cb = base::BindOnce(&C::F, instance);
|
||||||
|
/// std::move(cb).Run(); // Identical to instance->F()
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// See https://chromium.googlesource.com/chromium/src/+/lkgr/docs/callback.md
|
||||||
|
/// for the full documentation.
|
||||||
|
///
|
||||||
|
|
||||||
|
// Implementation notes
|
||||||
|
//
|
||||||
|
// If you're reading the implementation, before proceeding further, you should
|
||||||
|
// read the top comment of base/internal/cef_bind_internal.h for a definition
|
||||||
|
// of common terms and concepts.
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_BIND_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_BIND_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_BIND_H_
|
#define CEF_INCLUDE_BASE_CEF_BIND_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_BIND_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/bind.h"
|
#include "base/functional/bind.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include "include/base/internal/cef_bind_internal.h"
|
#include <functional>
|
||||||
#include "include/base/internal/cef_callback_internal.h"
|
#include <memory>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
#include "include/base/cef_build.h"
|
||||||
// Usage documentation
|
#include "include/base/cef_compiler_specific.h"
|
||||||
// -----------------------------------------------------------------------------
|
#include "include/base/internal/cef_bind_internal.h"
|
||||||
//
|
|
||||||
// See base/cef_callback.h for documentation.
|
#if defined(OS_APPLE) && !HAS_FEATURE(objc_arc)
|
||||||
//
|
#include "include/base/internal/cef_scoped_block_mac.h"
|
||||||
//
|
#endif
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Implementation notes
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// If you're reading the implementation, before proceeding further, you should
|
|
||||||
// read the top comment of base/bind_internal.h for a definition of common
|
|
||||||
// terms and concepts.
|
|
||||||
//
|
|
||||||
// RETURN TYPES
|
|
||||||
//
|
|
||||||
// Though Bind()'s result is meant to be stored in a Callback<> type, it
|
|
||||||
// cannot actually return the exact type without requiring a large amount
|
|
||||||
// of extra template specializations. The problem is that in order to
|
|
||||||
// discern the correct specialization of Callback<>, Bind would need to
|
|
||||||
// unwrap the function signature to determine the signature's arity, and
|
|
||||||
// whether or not it is a method.
|
|
||||||
//
|
|
||||||
// Each unique combination of (arity, function_type, num_prebound) where
|
|
||||||
// function_type is one of {function, method, const_method} would require
|
|
||||||
// one specialization. We eventually have to do a similar number of
|
|
||||||
// specializations anyways in the implementation (see the Invoker<>,
|
|
||||||
// classes). However, it is avoidable in Bind if we return the result
|
|
||||||
// via an indirection like we do below.
|
|
||||||
//
|
|
||||||
// TODO(ajwong): We might be able to avoid this now, but need to test.
|
|
||||||
//
|
|
||||||
// It is possible to move most of the COMPILE_ASSERT asserts into BindState<>,
|
|
||||||
// but it feels a little nicer to have the asserts here so people do not
|
|
||||||
// need to crack open bind_internal.h. On the other hand, it makes Bind()
|
|
||||||
// harder to read.
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template <typename Functor>
|
///
|
||||||
base::Callback<typename cef_internal::BindState<
|
/// Bind as OnceCallback.
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
///
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunType,
|
template <typename Functor, typename... Args>
|
||||||
void()>::UnboundRunType>
|
inline OnceCallback<cef_internal::MakeUnboundRunType<Functor, Args...>>
|
||||||
Bind(Functor functor) {
|
BindOnce(Functor&& functor, Args&&... args) {
|
||||||
// Typedefs for how to store and run the functor.
|
static_assert(!cef_internal::IsOnceCallback<std::decay_t<Functor>>() ||
|
||||||
typedef
|
(std::is_rvalue_reference<Functor&&>() &&
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
!std::is_const<std::remove_reference_t<Functor>>()),
|
||||||
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
"BindOnce requires non-const rvalue for OnceCallback binding."
|
||||||
|
" I.e.: base::BindOnce(std::move(callback)).");
|
||||||
|
static_assert(
|
||||||
|
std::conjunction<cef_internal::AssertBindArgIsNotBasePassed<
|
||||||
|
std::decay_t<Args>>...>::value,
|
||||||
|
"Use std::move() instead of base::Passed() with base::BindOnce()");
|
||||||
|
|
||||||
typedef cef_internal::BindState<RunnableType, RunType, void()> BindState;
|
return cef_internal::BindImpl<OnceCallback>(std::forward<Functor>(functor),
|
||||||
|
std::forward<Args>(args)...);
|
||||||
return Callback<typename BindState::UnboundRunType>(
|
|
||||||
new BindState(cef_internal::MakeRunnable(functor)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Functor, typename P1>
|
///
|
||||||
base::Callback<typename cef_internal::BindState<
|
/// Bind as RepeatingCallback.
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
///
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunType,
|
template <typename Functor, typename... Args>
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType)>::
|
inline RepeatingCallback<cef_internal::MakeUnboundRunType<Functor, Args...>>
|
||||||
UnboundRunType>
|
BindRepeating(Functor&& functor, Args&&... args) {
|
||||||
Bind(Functor functor, const P1& p1) {
|
static_assert(
|
||||||
// Typedefs for how to store and run the functor.
|
!cef_internal::IsOnceCallback<std::decay_t<Functor>>(),
|
||||||
typedef
|
"BindRepeating cannot bind OnceCallback. Use BindOnce with std::move().");
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
|
||||||
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
|
||||||
|
|
||||||
// Use RunnableType::RunType instead of RunType above because our
|
return cef_internal::BindImpl<RepeatingCallback>(
|
||||||
// checks should below for bound references need to know what the actual
|
std::forward<Functor>(functor), std::forward<Args>(args)...);
|
||||||
// functor is going to interpret the argument as.
|
|
||||||
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
|
||||||
BoundFunctorTraits;
|
|
||||||
|
|
||||||
// Do not allow binding a non-const reference parameter. Non-const reference
|
|
||||||
// parameters are disallowed by the Google style guide. Also, binding a
|
|
||||||
// non-const reference parameter can make for subtle bugs because the
|
|
||||||
// invoked function will receive a reference to the stored copy of the
|
|
||||||
// argument and not the original.
|
|
||||||
COMPILE_ASSERT(
|
|
||||||
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value),
|
|
||||||
do_not_bind_functions_with_nonconst_ref);
|
|
||||||
|
|
||||||
// For methods, we need to be careful for parameter 1. We do not require
|
|
||||||
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
|
||||||
// methods. We also disallow binding of an array as the method's target
|
|
||||||
// object.
|
|
||||||
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
|
||||||
p1_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!is_array<P1>::value,
|
|
||||||
first_bound_argument_to_method_cannot_be_array);
|
|
||||||
typedef cef_internal::BindState<
|
|
||||||
RunnableType, RunType,
|
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType)>
|
|
||||||
BindState;
|
|
||||||
|
|
||||||
return Callback<typename BindState::UnboundRunType>(
|
|
||||||
new BindState(cef_internal::MakeRunnable(functor), p1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Functor, typename P1, typename P2>
|
///
|
||||||
base::Callback<typename cef_internal::BindState<
|
/// Special cases for binding to a base::Callback without extra bound arguments.
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
/// We CHECK() the validity of callback to guard against null pointers
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunType,
|
/// accidentally ending up in posted tasks, causing hard-to-debug crashes.
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
///
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType)>::
|
template <typename Signature>
|
||||||
UnboundRunType>
|
OnceCallback<Signature> BindOnce(OnceCallback<Signature> callback) {
|
||||||
Bind(Functor functor, const P1& p1, const P2& p2) {
|
CHECK(callback);
|
||||||
// Typedefs for how to store and run the functor.
|
return callback;
|
||||||
typedef
|
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
|
||||||
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
|
||||||
|
|
||||||
// Use RunnableType::RunType instead of RunType above because our
|
|
||||||
// checks should below for bound references need to know what the actual
|
|
||||||
// functor is going to interpret the argument as.
|
|
||||||
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
|
||||||
BoundFunctorTraits;
|
|
||||||
|
|
||||||
// Do not allow binding a non-const reference parameter. Non-const reference
|
|
||||||
// parameters are disallowed by the Google style guide. Also, binding a
|
|
||||||
// non-const reference parameter can make for subtle bugs because the
|
|
||||||
// invoked function will receive a reference to the stored copy of the
|
|
||||||
// argument and not the original.
|
|
||||||
COMPILE_ASSERT(
|
|
||||||
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value),
|
|
||||||
do_not_bind_functions_with_nonconst_ref);
|
|
||||||
|
|
||||||
// For methods, we need to be careful for parameter 1. We do not require
|
|
||||||
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
|
||||||
// methods. We also disallow binding of an array as the method's target
|
|
||||||
// object.
|
|
||||||
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
|
||||||
p1_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!is_array<P1>::value,
|
|
||||||
first_bound_argument_to_method_cannot_be_array);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
|
||||||
p2_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
typedef cef_internal::BindState<
|
|
||||||
RunnableType, RunType,
|
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType)>
|
|
||||||
BindState;
|
|
||||||
|
|
||||||
return Callback<typename BindState::UnboundRunType>(
|
|
||||||
new BindState(cef_internal::MakeRunnable(functor), p1, p2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Functor, typename P1, typename P2, typename P3>
|
template <typename Signature>
|
||||||
base::Callback<typename cef_internal::BindState<
|
OnceCallback<Signature> BindOnce(RepeatingCallback<Signature> callback) {
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
CHECK(callback);
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunType,
|
return callback;
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType)>::
|
|
||||||
UnboundRunType>
|
|
||||||
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) {
|
|
||||||
// Typedefs for how to store and run the functor.
|
|
||||||
typedef
|
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
|
||||||
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
|
||||||
|
|
||||||
// Use RunnableType::RunType instead of RunType above because our
|
|
||||||
// checks should below for bound references need to know what the actual
|
|
||||||
// functor is going to interpret the argument as.
|
|
||||||
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
|
||||||
BoundFunctorTraits;
|
|
||||||
|
|
||||||
// Do not allow binding a non-const reference parameter. Non-const reference
|
|
||||||
// parameters are disallowed by the Google style guide. Also, binding a
|
|
||||||
// non-const reference parameter can make for subtle bugs because the
|
|
||||||
// invoked function will receive a reference to the stored copy of the
|
|
||||||
// argument and not the original.
|
|
||||||
COMPILE_ASSERT(
|
|
||||||
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value),
|
|
||||||
do_not_bind_functions_with_nonconst_ref);
|
|
||||||
|
|
||||||
// For methods, we need to be careful for parameter 1. We do not require
|
|
||||||
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
|
||||||
// methods. We also disallow binding of an array as the method's target
|
|
||||||
// object.
|
|
||||||
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
|
||||||
p1_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!is_array<P1>::value,
|
|
||||||
first_bound_argument_to_method_cannot_be_array);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
|
||||||
p2_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
|
||||||
p3_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
typedef cef_internal::BindState<
|
|
||||||
RunnableType, RunType,
|
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType)>
|
|
||||||
BindState;
|
|
||||||
|
|
||||||
return Callback<typename BindState::UnboundRunType>(
|
|
||||||
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Functor, typename P1, typename P2, typename P3, typename P4>
|
template <typename Signature>
|
||||||
base::Callback<typename cef_internal::BindState<
|
RepeatingCallback<Signature> BindRepeating(
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
RepeatingCallback<Signature> callback) {
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunType,
|
CHECK(callback);
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
return callback;
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P4>::StorageType)>::
|
|
||||||
UnboundRunType>
|
|
||||||
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) {
|
|
||||||
// Typedefs for how to store and run the functor.
|
|
||||||
typedef
|
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
|
||||||
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
|
||||||
|
|
||||||
// Use RunnableType::RunType instead of RunType above because our
|
|
||||||
// checks should below for bound references need to know what the actual
|
|
||||||
// functor is going to interpret the argument as.
|
|
||||||
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
|
||||||
BoundFunctorTraits;
|
|
||||||
|
|
||||||
// Do not allow binding a non-const reference parameter. Non-const reference
|
|
||||||
// parameters are disallowed by the Google style guide. Also, binding a
|
|
||||||
// non-const reference parameter can make for subtle bugs because the
|
|
||||||
// invoked function will receive a reference to the stored copy of the
|
|
||||||
// argument and not the original.
|
|
||||||
COMPILE_ASSERT(
|
|
||||||
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value),
|
|
||||||
do_not_bind_functions_with_nonconst_ref);
|
|
||||||
|
|
||||||
// For methods, we need to be careful for parameter 1. We do not require
|
|
||||||
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
|
||||||
// methods. We also disallow binding of an array as the method's target
|
|
||||||
// object.
|
|
||||||
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
|
||||||
p1_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!is_array<P1>::value,
|
|
||||||
first_bound_argument_to_method_cannot_be_array);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
|
||||||
p2_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
|
||||||
p3_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
|
|
||||||
p4_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
typedef cef_internal::BindState<
|
|
||||||
RunnableType, RunType,
|
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P4>::StorageType)>
|
|
||||||
BindState;
|
|
||||||
|
|
||||||
return Callback<typename BindState::UnboundRunType>(
|
|
||||||
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Functor,
|
///
|
||||||
typename P1,
|
/// Unretained() allows binding a non-refcounted class, and to disable
|
||||||
typename P2,
|
/// refcounting on arguments that are refcounted objects.
|
||||||
typename P3,
|
///
|
||||||
typename P4,
|
/// EXAMPLE OF Unretained():
|
||||||
typename P5>
|
///
|
||||||
base::Callback<typename cef_internal::BindState<
|
/// <pre>
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
/// class Foo {
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunType,
|
/// public:
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
/// void func() { cout << "Foo:f" << endl; }
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
/// };
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
///
|
||||||
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
/// // In some function somewhere.
|
||||||
typename cef_internal::CallbackParamTraits<P5>::StorageType)>::
|
/// Foo foo;
|
||||||
UnboundRunType>
|
/// OnceClosure foo_callback =
|
||||||
Bind(Functor functor,
|
/// BindOnce(&Foo::func, Unretained(&foo));
|
||||||
const P1& p1,
|
/// std::move(foo_callback).Run(); // Prints "Foo:f".
|
||||||
const P2& p2,
|
/// </pre>
|
||||||
const P3& p3,
|
///
|
||||||
const P4& p4,
|
/// Without the Unretained() wrapper on |&foo|, the above call would fail
|
||||||
const P5& p5) {
|
/// to compile because Foo does not support the AddRef() and Release() methods.
|
||||||
// Typedefs for how to store and run the functor.
|
///
|
||||||
typedef
|
template <typename T>
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
inline cef_internal::UnretainedWrapper<T> Unretained(T* o) {
|
||||||
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
return cef_internal::UnretainedWrapper<T>(o);
|
||||||
|
|
||||||
// Use RunnableType::RunType instead of RunType above because our
|
|
||||||
// checks should below for bound references need to know what the actual
|
|
||||||
// functor is going to interpret the argument as.
|
|
||||||
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
|
||||||
BoundFunctorTraits;
|
|
||||||
|
|
||||||
// Do not allow binding a non-const reference parameter. Non-const reference
|
|
||||||
// parameters are disallowed by the Google style guide. Also, binding a
|
|
||||||
// non-const reference parameter can make for subtle bugs because the
|
|
||||||
// invoked function will receive a reference to the stored copy of the
|
|
||||||
// argument and not the original.
|
|
||||||
COMPILE_ASSERT(
|
|
||||||
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value),
|
|
||||||
do_not_bind_functions_with_nonconst_ref);
|
|
||||||
|
|
||||||
// For methods, we need to be careful for parameter 1. We do not require
|
|
||||||
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
|
||||||
// methods. We also disallow binding of an array as the method's target
|
|
||||||
// object.
|
|
||||||
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
|
||||||
p1_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!is_array<P1>::value,
|
|
||||||
first_bound_argument_to_method_cannot_be_array);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
|
||||||
p2_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
|
||||||
p3_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
|
|
||||||
p4_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
|
|
||||||
p5_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
typedef cef_internal::BindState<
|
|
||||||
RunnableType, RunType,
|
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P5>::StorageType)>
|
|
||||||
BindState;
|
|
||||||
|
|
||||||
return Callback<typename BindState::UnboundRunType>(
|
|
||||||
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Functor,
|
///
|
||||||
typename P1,
|
/// RetainedRef() accepts a ref counted object and retains a reference to it.
|
||||||
typename P2,
|
/// When the callback is called, the object is passed as a raw pointer.
|
||||||
typename P3,
|
///
|
||||||
typename P4,
|
/// EXAMPLE OF RetainedRef():
|
||||||
typename P5,
|
///
|
||||||
typename P6>
|
/// <pre>
|
||||||
base::Callback<typename cef_internal::BindState<
|
/// void foo(RefCountedBytes* bytes) {}
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
///
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunType,
|
/// scoped_refptr<RefCountedBytes> bytes = ...;
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
/// OnceClosure callback = BindOnce(&foo, base::RetainedRef(bytes));
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
/// std::move(callback).Run();
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
/// </pre>
|
||||||
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
///
|
||||||
typename cef_internal::CallbackParamTraits<P5>::StorageType,
|
/// Without RetainedRef, the scoped_refptr would try to implicitly convert to
|
||||||
typename cef_internal::CallbackParamTraits<P6>::StorageType)>::
|
/// a raw pointer and fail compilation:
|
||||||
UnboundRunType>
|
///
|
||||||
Bind(Functor functor,
|
/// <pre>
|
||||||
const P1& p1,
|
/// OnceClosure callback = BindOnce(&foo, bytes); // ERROR!
|
||||||
const P2& p2,
|
/// </pre>
|
||||||
const P3& p3,
|
///
|
||||||
const P4& p4,
|
template <typename T>
|
||||||
const P5& p5,
|
inline cef_internal::RetainedRefWrapper<T> RetainedRef(T* o) {
|
||||||
const P6& p6) {
|
return cef_internal::RetainedRefWrapper<T>(o);
|
||||||
// Typedefs for how to store and run the functor.
|
}
|
||||||
typedef
|
template <typename T>
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
inline cef_internal::RetainedRefWrapper<T> RetainedRef(scoped_refptr<T> o) {
|
||||||
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
return cef_internal::RetainedRefWrapper<T>(std::move(o));
|
||||||
|
|
||||||
// Use RunnableType::RunType instead of RunType above because our
|
|
||||||
// checks should below for bound references need to know what the actual
|
|
||||||
// functor is going to interpret the argument as.
|
|
||||||
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
|
||||||
BoundFunctorTraits;
|
|
||||||
|
|
||||||
// Do not allow binding a non-const reference parameter. Non-const reference
|
|
||||||
// parameters are disallowed by the Google style guide. Also, binding a
|
|
||||||
// non-const reference parameter can make for subtle bugs because the
|
|
||||||
// invoked function will receive a reference to the stored copy of the
|
|
||||||
// argument and not the original.
|
|
||||||
COMPILE_ASSERT(
|
|
||||||
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A6Type>::value),
|
|
||||||
do_not_bind_functions_with_nonconst_ref);
|
|
||||||
|
|
||||||
// For methods, we need to be careful for parameter 1. We do not require
|
|
||||||
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
|
||||||
// methods. We also disallow binding of an array as the method's target
|
|
||||||
// object.
|
|
||||||
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
|
||||||
p1_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!is_array<P1>::value,
|
|
||||||
first_bound_argument_to_method_cannot_be_array);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
|
||||||
p2_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
|
||||||
p3_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
|
|
||||||
p4_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
|
|
||||||
p5_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P6>::value,
|
|
||||||
p6_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
typedef cef_internal::BindState<
|
|
||||||
RunnableType, RunType,
|
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P5>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P6>::StorageType)>
|
|
||||||
BindState;
|
|
||||||
|
|
||||||
return Callback<typename BindState::UnboundRunType>(new BindState(
|
|
||||||
cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Functor,
|
///
|
||||||
typename P1,
|
/// Owned() transfers ownership of an object to the callback resulting from
|
||||||
typename P2,
|
/// bind; the object will be deleted when the callback is deleted.
|
||||||
typename P3,
|
///
|
||||||
typename P4,
|
/// EXAMPLE OF Owned():
|
||||||
typename P5,
|
///
|
||||||
typename P6,
|
/// <pre>
|
||||||
typename P7>
|
/// void foo(int* arg) { cout << *arg << endl }
|
||||||
base::Callback<typename cef_internal::BindState<
|
///
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType,
|
/// int* pn = new int(1);
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunType,
|
/// RepeatingClosure foo_callback = BindRepeating(&foo, Owned(pn));
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
///
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
/// foo_callback.Run(); // Prints "1"
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
/// foo_callback.Run(); // Prints "1"
|
||||||
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
/// *pn = 2;
|
||||||
typename cef_internal::CallbackParamTraits<P5>::StorageType,
|
/// foo_callback.Run(); // Prints "2"
|
||||||
typename cef_internal::CallbackParamTraits<P6>::StorageType,
|
///
|
||||||
typename cef_internal::CallbackParamTraits<P7>::StorageType)>::
|
/// foo_callback.Reset(); // |pn| is deleted. Also will happen when
|
||||||
UnboundRunType>
|
/// // |foo_callback| goes out of scope.
|
||||||
Bind(Functor functor,
|
/// </pre>
|
||||||
const P1& p1,
|
///
|
||||||
const P2& p2,
|
/// Without Owned(), someone would have to know to delete |pn| when the last
|
||||||
const P3& p3,
|
/// reference to the callback is deleted.
|
||||||
const P4& p4,
|
///
|
||||||
const P5& p5,
|
template <typename T>
|
||||||
const P6& p6,
|
inline cef_internal::OwnedWrapper<T> Owned(T* o) {
|
||||||
const P7& p7) {
|
return cef_internal::OwnedWrapper<T>(o);
|
||||||
// Typedefs for how to store and run the functor.
|
|
||||||
typedef
|
|
||||||
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
|
|
||||||
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
|
|
||||||
|
|
||||||
// Use RunnableType::RunType instead of RunType above because our
|
|
||||||
// checks should below for bound references need to know what the actual
|
|
||||||
// functor is going to interpret the argument as.
|
|
||||||
typedef cef_internal::FunctionTraits<typename RunnableType::RunType>
|
|
||||||
BoundFunctorTraits;
|
|
||||||
|
|
||||||
// Do not allow binding a non-const reference parameter. Non-const reference
|
|
||||||
// parameters are disallowed by the Google style guide. Also, binding a
|
|
||||||
// non-const reference parameter can make for subtle bugs because the
|
|
||||||
// invoked function will receive a reference to the stored copy of the
|
|
||||||
// argument and not the original.
|
|
||||||
COMPILE_ASSERT(
|
|
||||||
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A6Type>::value ||
|
|
||||||
is_non_const_reference<typename BoundFunctorTraits::A7Type>::value),
|
|
||||||
do_not_bind_functions_with_nonconst_ref);
|
|
||||||
|
|
||||||
// For methods, we need to be careful for parameter 1. We do not require
|
|
||||||
// a scoped_refptr because BindState<> itself takes care of AddRef() for
|
|
||||||
// methods. We also disallow binding of an array as the method's target
|
|
||||||
// object.
|
|
||||||
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
|
|
||||||
p1_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
|
|
||||||
!is_array<P1>::value,
|
|
||||||
first_bound_argument_to_method_cannot_be_array);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
|
|
||||||
p2_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
|
|
||||||
p3_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
|
|
||||||
p4_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
|
|
||||||
p5_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P6>::value,
|
|
||||||
p6_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P7>::value,
|
|
||||||
p7_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
typedef cef_internal::BindState<
|
|
||||||
RunnableType, RunType,
|
|
||||||
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P2>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P3>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P4>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P5>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P6>::StorageType,
|
|
||||||
typename cef_internal::CallbackParamTraits<P7>::StorageType)>
|
|
||||||
BindState;
|
|
||||||
|
|
||||||
return Callback<typename BindState::UnboundRunType>(new BindState(
|
|
||||||
cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6, p7));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, typename Deleter>
|
||||||
|
inline cef_internal::OwnedWrapper<T, Deleter> Owned(
|
||||||
|
std::unique_ptr<T, Deleter>&& ptr) {
|
||||||
|
return cef_internal::OwnedWrapper<T, Deleter>(std::move(ptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// OwnedRef() stores an object in the callback resulting from
|
||||||
|
/// bind and passes a reference to the object to the bound function.
|
||||||
|
///
|
||||||
|
/// EXAMPLE OF OwnedRef():
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// void foo(int& arg) { cout << ++arg << endl }
|
||||||
|
///
|
||||||
|
/// int counter = 0;
|
||||||
|
/// RepeatingClosure foo_callback = BindRepeating(&foo, OwnedRef(counter));
|
||||||
|
///
|
||||||
|
/// foo_callback.Run(); // Prints "1"
|
||||||
|
/// foo_callback.Run(); // Prints "2"
|
||||||
|
/// foo_callback.Run(); // Prints "3"
|
||||||
|
///
|
||||||
|
/// cout << counter; // Prints "0", OwnedRef creates a copy of counter.
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// Supports OnceCallbacks as well, useful to pass placeholder arguments:
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// void bar(int& ignore, const std::string& s) { cout << s << endl }
|
||||||
|
///
|
||||||
|
/// OnceClosure bar_callback = BindOnce(&bar, OwnedRef(0), "Hello");
|
||||||
|
///
|
||||||
|
/// std::move(bar_callback).Run(); // Prints "Hello"
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// Without OwnedRef() it would not be possible to pass a mutable reference to
|
||||||
|
/// an object owned by the callback.
|
||||||
|
///
|
||||||
|
template <typename T>
|
||||||
|
cef_internal::OwnedRefWrapper<std::decay_t<T>> OwnedRef(T&& t) {
|
||||||
|
return cef_internal::OwnedRefWrapper<std::decay_t<T>>(std::forward<T>(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Passed() is for transferring movable-but-not-copyable types (eg. unique_ptr)
|
||||||
|
/// through a RepeatingCallback. Logically, this signifies a destructive
|
||||||
|
/// transfer of the state of the argument into the target function. Invoking
|
||||||
|
/// RepeatingCallback::Run() twice on a callback that was created with a
|
||||||
|
/// Passed() argument will CHECK() because the first invocation would have
|
||||||
|
/// already transferred ownership to the target function.
|
||||||
|
///
|
||||||
|
/// Note that Passed() is not necessary with BindOnce(), as std::move() does the
|
||||||
|
/// same thing. Avoid Passed() in favor of std::move() with BindOnce().
|
||||||
|
///
|
||||||
|
/// EXAMPLE OF Passed():
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// void TakesOwnership(std::unique_ptr<Foo> arg) { }
|
||||||
|
/// std::unique_ptr<Foo> CreateFoo() { return std::make_unique<Foo>();
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// auto f = std::make_unique<Foo>();
|
||||||
|
///
|
||||||
|
/// // |cb| is given ownership of Foo(). |f| is now NULL.
|
||||||
|
/// // You can use std::move(f) in place of &f, but it's more verbose.
|
||||||
|
/// RepeatingClosure cb = BindRepeating(&TakesOwnership, Passed(&f));
|
||||||
|
///
|
||||||
|
/// // Run was never called so |cb| still owns Foo() and deletes
|
||||||
|
/// // it on Reset().
|
||||||
|
/// cb.Reset();
|
||||||
|
///
|
||||||
|
/// // |cb| is given a new Foo created by CreateFoo().
|
||||||
|
/// cb = BindRepeating(&TakesOwnership, Passed(CreateFoo()));
|
||||||
|
///
|
||||||
|
/// // |arg| in TakesOwnership() is given ownership of Foo(). |cb|
|
||||||
|
/// // no longer owns Foo() and, if reset, would not delete Foo().
|
||||||
|
/// cb.Run(); // Foo() is now transferred to |arg| and deleted.
|
||||||
|
/// cb.Run(); // This CHECK()s since Foo() already been used once.
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// We offer 2 syntaxes for calling Passed(). The first takes an rvalue and is
|
||||||
|
/// best suited for use with the return value of a function or other temporary
|
||||||
|
/// rvalues. The second takes a pointer to the scoper and is just syntactic
|
||||||
|
/// sugar to avoid having to write Passed(std::move(scoper)).
|
||||||
|
///
|
||||||
|
/// Both versions of Passed() prevent T from being an lvalue reference. The
|
||||||
|
/// first via use of enable_if, and the second takes a T* which will not bind to
|
||||||
|
/// T&.
|
||||||
|
///
|
||||||
|
template <typename T,
|
||||||
|
std::enable_if_t<!std::is_lvalue_reference<T>::value>* = nullptr>
|
||||||
|
inline cef_internal::PassedWrapper<T> Passed(T&& scoper) {
|
||||||
|
return cef_internal::PassedWrapper<T>(std::move(scoper));
|
||||||
|
}
|
||||||
|
template <typename T>
|
||||||
|
inline cef_internal::PassedWrapper<T> Passed(T* scoper) {
|
||||||
|
return cef_internal::PassedWrapper<T>(std::move(*scoper));
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// IgnoreResult() is used to adapt a function or callback with a return type to
|
||||||
|
/// one with a void return. This is most useful if you have a function with,
|
||||||
|
/// say, a pesky ignorable bool return that you want to use with PostTask or
|
||||||
|
/// something else that expect a callback with a void return.
|
||||||
|
///
|
||||||
|
/// EXAMPLE OF IgnoreResult():
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// int DoSomething(int arg) { cout << arg << endl; }
|
||||||
|
///
|
||||||
|
/// // Assign to a callback with a void return type.
|
||||||
|
/// OnceCallback<void(int)> cb = BindOnce(IgnoreResult(&DoSomething));
|
||||||
|
/// std::move(cb).Run(1); // Prints "1".
|
||||||
|
///
|
||||||
|
/// // Prints "2" on |ml|.
|
||||||
|
/// ml->PostTask(FROM_HERE, BindOnce(IgnoreResult(&DoSomething), 2);
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
template <typename T>
|
||||||
|
inline cef_internal::IgnoreResultHelper<T> IgnoreResult(T data) {
|
||||||
|
return cef_internal::IgnoreResultHelper<T>(std::move(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(OS_APPLE) && !HAS_FEATURE(objc_arc)
|
||||||
|
|
||||||
|
///
|
||||||
|
/// RetainBlock() is used to adapt an Objective-C block when Automated Reference
|
||||||
|
/// Counting (ARC) is disabled. This is unnecessary when ARC is enabled, as the
|
||||||
|
/// BindOnce and BindRepeating already support blocks then.
|
||||||
|
///
|
||||||
|
/// EXAMPLE OF RetainBlock():
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// // Wrap the block and bind it to a callback.
|
||||||
|
/// OnceCallback<void(int)> cb =
|
||||||
|
/// BindOnce(RetainBlock(^(int n) { NSLog(@"%d", n); }));
|
||||||
|
/// std::move(cb).Run(1); // Logs "1".
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
template <typename R, typename... Args>
|
||||||
|
base::mac::ScopedBlock<R (^)(Args...)> RetainBlock(R (^block)(Args...)) {
|
||||||
|
return base::mac::ScopedBlock<R (^)(Args...)>(block,
|
||||||
|
base::scoped_policy::RETAIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(OS_APPLE) && !HAS_FEATURE(objc_arc)
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|||||||
@@ -1,579 +0,0 @@
|
|||||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
|
||||||
// Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// This defines a set of argument wrappers and related factory methods that
|
|
||||||
// can be used specify the refcounting and reference semantics of arguments
|
|
||||||
// that are bound by the Bind() function in base/bind.h.
|
|
||||||
//
|
|
||||||
// It also defines a set of simple functions and utilities that people want
|
|
||||||
// when using Callback<> and Bind().
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// ARGUMENT BINDING WRAPPERS
|
|
||||||
//
|
|
||||||
// The wrapper functions are base::Unretained(), base::Owned(), base::Passed(),
|
|
||||||
// base::ConstRef(), and base::IgnoreResult().
|
|
||||||
//
|
|
||||||
// Unretained() allows Bind() to bind a non-refcounted class, and to disable
|
|
||||||
// refcounting on arguments that are refcounted objects.
|
|
||||||
//
|
|
||||||
// Owned() transfers ownership of an object to the Callback resulting from
|
|
||||||
// bind; the object will be deleted when the Callback is deleted.
|
|
||||||
//
|
|
||||||
// Passed() is for transferring movable-but-not-copyable types (eg. scoped_ptr)
|
|
||||||
// through a Callback. Logically, this signifies a destructive transfer of
|
|
||||||
// the state of the argument into the target function. Invoking
|
|
||||||
// Callback::Run() twice on a Callback that was created with a Passed()
|
|
||||||
// argument will CHECK() because the first invocation would have already
|
|
||||||
// transferred ownership to the target function.
|
|
||||||
//
|
|
||||||
// ConstRef() allows binding a constant reference to an argument rather
|
|
||||||
// than a copy.
|
|
||||||
//
|
|
||||||
// IgnoreResult() is used to adapt a function or Callback with a return type to
|
|
||||||
// one with a void return. This is most useful if you have a function with,
|
|
||||||
// say, a pesky ignorable bool return that you want to use with PostTask or
|
|
||||||
// something else that expect a Callback with a void return.
|
|
||||||
//
|
|
||||||
// EXAMPLE OF Unretained():
|
|
||||||
//
|
|
||||||
// class Foo {
|
|
||||||
// public:
|
|
||||||
// void func() { cout << "Foo:f" << endl; }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// // In some function somewhere.
|
|
||||||
// Foo foo;
|
|
||||||
// Closure foo_callback =
|
|
||||||
// Bind(&Foo::func, Unretained(&foo));
|
|
||||||
// foo_callback.Run(); // Prints "Foo:f".
|
|
||||||
//
|
|
||||||
// Without the Unretained() wrapper on |&foo|, the above call would fail
|
|
||||||
// to compile because Foo does not support the AddRef() and Release() methods.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// EXAMPLE OF Owned():
|
|
||||||
//
|
|
||||||
// void foo(int* arg) { cout << *arg << endl }
|
|
||||||
//
|
|
||||||
// int* pn = new int(1);
|
|
||||||
// Closure foo_callback = Bind(&foo, Owned(pn));
|
|
||||||
//
|
|
||||||
// foo_callback.Run(); // Prints "1"
|
|
||||||
// foo_callback.Run(); // Prints "1"
|
|
||||||
// *n = 2;
|
|
||||||
// foo_callback.Run(); // Prints "2"
|
|
||||||
//
|
|
||||||
// foo_callback.Reset(); // |pn| is deleted. Also will happen when
|
|
||||||
// // |foo_callback| goes out of scope.
|
|
||||||
//
|
|
||||||
// Without Owned(), someone would have to know to delete |pn| when the last
|
|
||||||
// reference to the Callback is deleted.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// EXAMPLE OF ConstRef():
|
|
||||||
//
|
|
||||||
// void foo(int arg) { cout << arg << endl }
|
|
||||||
//
|
|
||||||
// int n = 1;
|
|
||||||
// Closure no_ref = Bind(&foo, n);
|
|
||||||
// Closure has_ref = Bind(&foo, ConstRef(n));
|
|
||||||
//
|
|
||||||
// no_ref.Run(); // Prints "1"
|
|
||||||
// has_ref.Run(); // Prints "1"
|
|
||||||
//
|
|
||||||
// n = 2;
|
|
||||||
// no_ref.Run(); // Prints "1"
|
|
||||||
// has_ref.Run(); // Prints "2"
|
|
||||||
//
|
|
||||||
// Note that because ConstRef() takes a reference on |n|, |n| must outlive all
|
|
||||||
// its bound callbacks.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// EXAMPLE OF IgnoreResult():
|
|
||||||
//
|
|
||||||
// int DoSomething(int arg) { cout << arg << endl; }
|
|
||||||
//
|
|
||||||
// // Assign to a Callback with a void return type.
|
|
||||||
// Callback<void(int)> cb = Bind(IgnoreResult(&DoSomething));
|
|
||||||
// cb->Run(1); // Prints "1".
|
|
||||||
//
|
|
||||||
// // Prints "1" on |ml|.
|
|
||||||
// ml->PostTask(FROM_HERE, Bind(IgnoreResult(&DoSomething), 1);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// EXAMPLE OF Passed():
|
|
||||||
//
|
|
||||||
// void TakesOwnership(scoped_ptr<Foo> arg) { }
|
|
||||||
// scoped_ptr<Foo> CreateFoo() { return scoped_ptr<Foo>(new Foo()); }
|
|
||||||
//
|
|
||||||
// scoped_ptr<Foo> f(new Foo());
|
|
||||||
//
|
|
||||||
// // |cb| is given ownership of Foo(). |f| is now NULL.
|
|
||||||
// // You can use f.Pass() in place of &f, but it's more verbose.
|
|
||||||
// Closure cb = Bind(&TakesOwnership, Passed(&f));
|
|
||||||
//
|
|
||||||
// // Run was never called so |cb| still owns Foo() and deletes
|
|
||||||
// // it on Reset().
|
|
||||||
// cb.Reset();
|
|
||||||
//
|
|
||||||
// // |cb| is given a new Foo created by CreateFoo().
|
|
||||||
// cb = Bind(&TakesOwnership, Passed(CreateFoo()));
|
|
||||||
//
|
|
||||||
// // |arg| in TakesOwnership() is given ownership of Foo(). |cb|
|
|
||||||
// // no longer owns Foo() and, if reset, would not delete Foo().
|
|
||||||
// cb.Run(); // Foo() is now transferred to |arg| and deleted.
|
|
||||||
// cb.Run(); // This CHECK()s since Foo() already been used once.
|
|
||||||
//
|
|
||||||
// Passed() is particularly useful with PostTask() when you are transferring
|
|
||||||
// ownership of an argument into a task, but don't necessarily know if the
|
|
||||||
// task will always be executed. This can happen if the task is cancellable
|
|
||||||
// or if it is posted to a MessageLoopProxy.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// SIMPLE FUNCTIONS AND UTILITIES.
|
|
||||||
//
|
|
||||||
// DoNothing() - Useful for creating a Closure that does nothing when called.
|
|
||||||
// DeletePointer<T>() - Useful for creating a Closure that will delete a
|
|
||||||
// pointer when invoked. Only use this when necessary.
|
|
||||||
// In most cases MessageLoop::DeleteSoon() is a better
|
|
||||||
// fit.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_BIND_HELPERS_H_
|
|
||||||
#define CEF_INCLUDE_BASE_CEF_BIND_HELPERS_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(BASE_BIND_HELPERS_H_)
|
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
|
||||||
#include "base/bind_helpers.h"
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
|
||||||
// The following is substantially similar to the Chromium implementation.
|
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
|
||||||
// updated to match.
|
|
||||||
|
|
||||||
#include "include/base/cef_basictypes.h"
|
|
||||||
#include "include/base/cef_callback.h"
|
|
||||||
#include "include/base/cef_template_util.h"
|
|
||||||
#include "include/base/cef_weak_ptr.h"
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
namespace cef_internal {
|
|
||||||
|
|
||||||
// Use the Substitution Failure Is Not An Error (SFINAE) trick to inspect T
|
|
||||||
// for the existence of AddRef() and Release() functions of the correct
|
|
||||||
// signature.
|
|
||||||
//
|
|
||||||
// http://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error
|
|
||||||
// http://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence
|
|
||||||
// http://stackoverflow.com/questions/4358584/sfinae-approach-comparison
|
|
||||||
// http://stackoverflow.com/questions/1966362/sfinae-to-check-for-inherited-member-functions
|
|
||||||
//
|
|
||||||
// The last link in particular show the method used below.
|
|
||||||
//
|
|
||||||
// For SFINAE to work with inherited methods, we need to pull some extra tricks
|
|
||||||
// with multiple inheritance. In the more standard formulation, the overloads
|
|
||||||
// of Check would be:
|
|
||||||
//
|
|
||||||
// template <typename C>
|
|
||||||
// Yes NotTheCheckWeWant(Helper<&C::TargetFunc>*);
|
|
||||||
//
|
|
||||||
// template <typename C>
|
|
||||||
// No NotTheCheckWeWant(...);
|
|
||||||
//
|
|
||||||
// static const bool value = sizeof(NotTheCheckWeWant<T>(0)) == sizeof(Yes);
|
|
||||||
//
|
|
||||||
// The problem here is that template resolution will not match
|
|
||||||
// C::TargetFunc if TargetFunc does not exist directly in C. That is, if
|
|
||||||
// TargetFunc in inherited from an ancestor, &C::TargetFunc will not match,
|
|
||||||
// |value| will be false. This formulation only checks for whether or
|
|
||||||
// not TargetFunc exist directly in the class being introspected.
|
|
||||||
//
|
|
||||||
// To get around this, we play a dirty trick with multiple inheritance.
|
|
||||||
// First, We create a class BaseMixin that declares each function that we
|
|
||||||
// want to probe for. Then we create a class Base that inherits from both T
|
|
||||||
// (the class we wish to probe) and BaseMixin. Note that the function
|
|
||||||
// signature in BaseMixin does not need to match the signature of the function
|
|
||||||
// we are probing for; thus it's easiest to just use void(void).
|
|
||||||
//
|
|
||||||
// Now, if TargetFunc exists somewhere in T, then &Base::TargetFunc has an
|
|
||||||
// ambiguous resolution between BaseMixin and T. This lets us write the
|
|
||||||
// following:
|
|
||||||
//
|
|
||||||
// template <typename C>
|
|
||||||
// No GoodCheck(Helper<&C::TargetFunc>*);
|
|
||||||
//
|
|
||||||
// template <typename C>
|
|
||||||
// Yes GoodCheck(...);
|
|
||||||
//
|
|
||||||
// static const bool value = sizeof(GoodCheck<Base>(0)) == sizeof(Yes);
|
|
||||||
//
|
|
||||||
// Notice here that the variadic version of GoodCheck() returns Yes here
|
|
||||||
// instead of No like the previous one. Also notice that we calculate |value|
|
|
||||||
// by specializing GoodCheck() on Base instead of T.
|
|
||||||
//
|
|
||||||
// We've reversed the roles of the variadic, and Helper overloads.
|
|
||||||
// GoodCheck(Helper<&C::TargetFunc>*), when C = Base, fails to be a valid
|
|
||||||
// substitution if T::TargetFunc exists. Thus GoodCheck<Base>(0) will resolve
|
|
||||||
// to the variadic version if T has TargetFunc. If T::TargetFunc does not
|
|
||||||
// exist, then &C::TargetFunc is not ambiguous, and the overload resolution
|
|
||||||
// will prefer GoodCheck(Helper<&C::TargetFunc>*).
|
|
||||||
//
|
|
||||||
// This method of SFINAE will correctly probe for inherited names, but it cannot
|
|
||||||
// typecheck those names. It's still a good enough sanity check though.
|
|
||||||
//
|
|
||||||
// Works on gcc-4.2, gcc-4.4, and Visual Studio 2008.
|
|
||||||
//
|
|
||||||
// TODO(ajwong): Move to ref_counted.h or template_util.h when we've vetted
|
|
||||||
// this works well.
|
|
||||||
//
|
|
||||||
// TODO(ajwong): Make this check for Release() as well.
|
|
||||||
// See http://crbug.com/82038.
|
|
||||||
template <typename T>
|
|
||||||
class SupportsAddRefAndRelease {
|
|
||||||
typedef char Yes[1];
|
|
||||||
typedef char No[2];
|
|
||||||
|
|
||||||
struct BaseMixin {
|
|
||||||
void AddRef();
|
|
||||||
};
|
|
||||||
|
|
||||||
// MSVC warns when you try to use Base if T has a private destructor, the
|
|
||||||
// common pattern for refcounted types. It does this even though no attempt to
|
|
||||||
// instantiate Base is made. We disable the warning for this definition.
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable : 4624)
|
|
||||||
#endif
|
|
||||||
struct Base : public T, public BaseMixin {};
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <void (BaseMixin::*)(void)>
|
|
||||||
struct Helper {};
|
|
||||||
|
|
||||||
template <typename C>
|
|
||||||
static No& Check(Helper<&C::AddRef>*);
|
|
||||||
|
|
||||||
template <typename>
|
|
||||||
static Yes& Check(...);
|
|
||||||
|
|
||||||
public:
|
|
||||||
static const bool value = sizeof(Check<Base>(0)) == sizeof(Yes);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Helpers to assert that arguments of a recounted type are bound with a
|
|
||||||
// scoped_refptr.
|
|
||||||
template <bool IsClasstype, typename T>
|
|
||||||
struct UnsafeBindtoRefCountedArgHelper : false_type {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnsafeBindtoRefCountedArgHelper<true, T>
|
|
||||||
: integral_constant<bool, SupportsAddRefAndRelease<T>::value> {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnsafeBindtoRefCountedArg : false_type {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnsafeBindtoRefCountedArg<T*>
|
|
||||||
: UnsafeBindtoRefCountedArgHelper<is_class<T>::value, T> {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class HasIsMethodTag {
|
|
||||||
typedef char Yes[1];
|
|
||||||
typedef char No[2];
|
|
||||||
|
|
||||||
template <typename U>
|
|
||||||
static Yes& Check(typename U::IsMethod*);
|
|
||||||
|
|
||||||
template <typename U>
|
|
||||||
static No& Check(...);
|
|
||||||
|
|
||||||
public:
|
|
||||||
static const bool value = sizeof(Check<T>(0)) == sizeof(Yes);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class UnretainedWrapper {
|
|
||||||
public:
|
|
||||||
explicit UnretainedWrapper(T* o) : ptr_(o) {}
|
|
||||||
T* get() const { return ptr_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
T* ptr_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class ConstRefWrapper {
|
|
||||||
public:
|
|
||||||
explicit ConstRefWrapper(const T& o) : ptr_(&o) {}
|
|
||||||
const T& get() const { return *ptr_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
const T* ptr_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct IgnoreResultHelper {
|
|
||||||
explicit IgnoreResultHelper(T functor) : functor_(functor) {}
|
|
||||||
|
|
||||||
T functor_;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct IgnoreResultHelper<Callback<T>> {
|
|
||||||
explicit IgnoreResultHelper(const Callback<T>& functor) : functor_(functor) {}
|
|
||||||
|
|
||||||
const Callback<T>& functor_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// An alternate implementation is to avoid the destructive copy, and instead
|
|
||||||
// specialize ParamTraits<> for OwnedWrapper<> to change the StorageType to
|
|
||||||
// a class that is essentially a scoped_ptr<>.
|
|
||||||
//
|
|
||||||
// The current implementation has the benefit though of leaving ParamTraits<>
|
|
||||||
// fully in callback_internal.h as well as avoiding type conversions during
|
|
||||||
// storage.
|
|
||||||
template <typename T>
|
|
||||||
class OwnedWrapper {
|
|
||||||
public:
|
|
||||||
explicit OwnedWrapper(T* o) : ptr_(o) {}
|
|
||||||
~OwnedWrapper() { delete ptr_; }
|
|
||||||
T* get() const { return ptr_; }
|
|
||||||
OwnedWrapper(const OwnedWrapper& other) {
|
|
||||||
ptr_ = other.ptr_;
|
|
||||||
other.ptr_ = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
mutable T* ptr_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// PassedWrapper is a copyable adapter for a scoper that ignores const.
|
|
||||||
//
|
|
||||||
// It is needed to get around the fact that Bind() takes a const reference to
|
|
||||||
// all its arguments. Because Bind() takes a const reference to avoid
|
|
||||||
// unnecessary copies, it is incompatible with movable-but-not-copyable
|
|
||||||
// types; doing a destructive "move" of the type into Bind() would violate
|
|
||||||
// the const correctness.
|
|
||||||
//
|
|
||||||
// This conundrum cannot be solved without either C++11 rvalue references or
|
|
||||||
// a O(2^n) blowup of Bind() templates to handle each combination of regular
|
|
||||||
// types and movable-but-not-copyable types. Thus we introduce a wrapper type
|
|
||||||
// that is copyable to transmit the correct type information down into
|
|
||||||
// BindState<>. Ignoring const in this type makes sense because it is only
|
|
||||||
// created when we are explicitly trying to do a destructive move.
|
|
||||||
//
|
|
||||||
// Two notes:
|
|
||||||
// 1) PassedWrapper supports any type that has a "Pass()" function.
|
|
||||||
// This is intentional. The whitelisting of which specific types we
|
|
||||||
// support is maintained by CallbackParamTraits<>.
|
|
||||||
// 2) is_valid_ is distinct from NULL because it is valid to bind a "NULL"
|
|
||||||
// scoper to a Callback and allow the Callback to execute once.
|
|
||||||
template <typename T>
|
|
||||||
class PassedWrapper {
|
|
||||||
public:
|
|
||||||
explicit PassedWrapper(T scoper) : is_valid_(true), scoper_(scoper.Pass()) {}
|
|
||||||
PassedWrapper(const PassedWrapper& other)
|
|
||||||
: is_valid_(other.is_valid_), scoper_(other.scoper_.Pass()) {}
|
|
||||||
T Pass() const {
|
|
||||||
CHECK(is_valid_);
|
|
||||||
is_valid_ = false;
|
|
||||||
return scoper_.Pass();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
mutable bool is_valid_;
|
|
||||||
mutable T scoper_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Unwrap the stored parameters for the wrappers above.
|
|
||||||
template <typename T>
|
|
||||||
struct UnwrapTraits {
|
|
||||||
typedef const T& ForwardType;
|
|
||||||
static ForwardType Unwrap(const T& o) { return o; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnwrapTraits<UnretainedWrapper<T>> {
|
|
||||||
typedef T* ForwardType;
|
|
||||||
static ForwardType Unwrap(UnretainedWrapper<T> unretained) {
|
|
||||||
return unretained.get();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnwrapTraits<ConstRefWrapper<T>> {
|
|
||||||
typedef const T& ForwardType;
|
|
||||||
static ForwardType Unwrap(ConstRefWrapper<T> const_ref) {
|
|
||||||
return const_ref.get();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnwrapTraits<scoped_refptr<T>> {
|
|
||||||
typedef T* ForwardType;
|
|
||||||
static ForwardType Unwrap(const scoped_refptr<T>& o) { return o.get(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnwrapTraits<WeakPtr<T>> {
|
|
||||||
typedef const WeakPtr<T>& ForwardType;
|
|
||||||
static ForwardType Unwrap(const WeakPtr<T>& o) { return o; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnwrapTraits<OwnedWrapper<T>> {
|
|
||||||
typedef T* ForwardType;
|
|
||||||
static ForwardType Unwrap(const OwnedWrapper<T>& o) { return o.get(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct UnwrapTraits<PassedWrapper<T>> {
|
|
||||||
typedef T ForwardType;
|
|
||||||
static T Unwrap(PassedWrapper<T>& o) { return o.Pass(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Utility for handling different refcounting semantics in the Bind()
|
|
||||||
// function.
|
|
||||||
template <bool is_method, typename T>
|
|
||||||
struct MaybeRefcount;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct MaybeRefcount<false, T> {
|
|
||||||
static void AddRef(const T&) {}
|
|
||||||
static void Release(const T&) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, size_t n>
|
|
||||||
struct MaybeRefcount<false, T[n]> {
|
|
||||||
static void AddRef(const T*) {}
|
|
||||||
static void Release(const T*) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct MaybeRefcount<true, T> {
|
|
||||||
static void AddRef(const T&) {}
|
|
||||||
static void Release(const T&) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct MaybeRefcount<true, T*> {
|
|
||||||
static void AddRef(T* o) { o->AddRef(); }
|
|
||||||
static void Release(T* o) { o->Release(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// No need to additionally AddRef() and Release() since we are storing a
|
|
||||||
// scoped_refptr<> inside the storage object already.
|
|
||||||
template <typename T>
|
|
||||||
struct MaybeRefcount<true, scoped_refptr<T>> {
|
|
||||||
static void AddRef(const scoped_refptr<T>& o) {}
|
|
||||||
static void Release(const scoped_refptr<T>& o) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct MaybeRefcount<true, const T*> {
|
|
||||||
static void AddRef(const T* o) { o->AddRef(); }
|
|
||||||
static void Release(const T* o) { o->Release(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// IsWeakMethod is a helper that determine if we are binding a WeakPtr<> to a
|
|
||||||
// method. It is used internally by Bind() to select the correct
|
|
||||||
// InvokeHelper that will no-op itself in the event the WeakPtr<> for
|
|
||||||
// the target object is invalidated.
|
|
||||||
//
|
|
||||||
// P1 should be the type of the object that will be received of the method.
|
|
||||||
template <bool IsMethod, typename P1>
|
|
||||||
struct IsWeakMethod : public false_type {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct IsWeakMethod<true, WeakPtr<T>> : public true_type {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct IsWeakMethod<true, ConstRefWrapper<WeakPtr<T>>> : public true_type {};
|
|
||||||
|
|
||||||
} // namespace cef_internal
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static inline cef_internal::UnretainedWrapper<T> Unretained(T* o) {
|
|
||||||
return cef_internal::UnretainedWrapper<T>(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static inline cef_internal::ConstRefWrapper<T> ConstRef(const T& o) {
|
|
||||||
return cef_internal::ConstRefWrapper<T>(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static inline cef_internal::OwnedWrapper<T> Owned(T* o) {
|
|
||||||
return cef_internal::OwnedWrapper<T>(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We offer 2 syntaxes for calling Passed(). The first takes a temporary and
|
|
||||||
// is best suited for use with the return value of a function. The second
|
|
||||||
// takes a pointer to the scoper and is just syntactic sugar to avoid having
|
|
||||||
// to write Passed(scoper.Pass()).
|
|
||||||
template <typename T>
|
|
||||||
static inline cef_internal::PassedWrapper<T> Passed(T scoper) {
|
|
||||||
return cef_internal::PassedWrapper<T>(scoper.Pass());
|
|
||||||
}
|
|
||||||
template <typename T>
|
|
||||||
static inline cef_internal::PassedWrapper<T> Passed(T* scoper) {
|
|
||||||
return cef_internal::PassedWrapper<T>(scoper->Pass());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static inline cef_internal::IgnoreResultHelper<T> IgnoreResult(T data) {
|
|
||||||
return cef_internal::IgnoreResultHelper<T>(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
static inline cef_internal::IgnoreResultHelper<Callback<T>> IgnoreResult(
|
|
||||||
const Callback<T>& data) {
|
|
||||||
return cef_internal::IgnoreResultHelper<Callback<T>>(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoNothing();
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void DeletePointer(T* obj) {
|
|
||||||
delete obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_BIND_HELPERS_H_
|
|
||||||
@@ -27,53 +27,149 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
/// \file
|
||||||
|
/// This file adds defines about the platform we're currently building on.
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// Operating System:
|
||||||
|
/// OS_AIX / OS_ANDROID / OS_ASMJS / OS_FREEBSD / OS_FUCHSIA / OS_IOS /
|
||||||
|
/// OS_LINUX / OS_MAC / OS_NACL (SFI or NONSFI) / OS_NETBSD / OS_OPENBSD /
|
||||||
|
/// OS_QNX / OS_SOLARIS / OS_WIN
|
||||||
|
/// Operating System family:
|
||||||
|
/// OS_APPLE: IOS or MAC
|
||||||
|
/// OS_BSD: FREEBSD or NETBSD or OPENBSD
|
||||||
|
/// OS_POSIX: AIX or ANDROID or ASMJS or CHROMEOS or FREEBSD or IOS or LINUX
|
||||||
|
/// or MAC or NACL or NETBSD or OPENBSD or QNX or SOLARIS
|
||||||
|
///
|
||||||
|
/// /!\ Note: OS_CHROMEOS is set by the build system, not this file
|
||||||
|
///
|
||||||
|
/// Compiler:
|
||||||
|
/// COMPILER_MSVC / COMPILER_GCC
|
||||||
|
///
|
||||||
|
/// Processor:
|
||||||
|
/// ARCH_CPU_ARM64 / ARCH_CPU_ARMEL / ARCH_CPU_MIPS / ARCH_CPU_MIPS64 /
|
||||||
|
/// ARCH_CPU_MIPS64EL / ARCH_CPU_MIPSEL / ARCH_CPU_PPC64 / ARCH_CPU_S390 /
|
||||||
|
/// ARCH_CPU_S390X / ARCH_CPU_X86 / ARCH_CPU_X86_64
|
||||||
|
/// Processor family:
|
||||||
|
/// ARCH_CPU_ARM_FAMILY: ARMEL or ARM64
|
||||||
|
/// ARCH_CPU_MIPS_FAMILY: MIPS64EL or MIPSEL or MIPS64 or MIPS
|
||||||
|
/// ARCH_CPU_PPC64_FAMILY: PPC64
|
||||||
|
/// ARCH_CPU_S390_FAMILY: S390 or S390X
|
||||||
|
/// ARCH_CPU_X86_FAMILY: X86 or X86_64
|
||||||
|
/// Processor features:
|
||||||
|
/// ARCH_CPU_31_BITS / ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
|
||||||
|
/// ARCH_CPU_BIG_ENDIAN / ARCH_CPU_LITTLE_ENDIAN
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_BUILD_H_
|
#define CEF_INCLUDE_BASE_CEF_BUILD_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/compiler_specific.h"
|
#include "build/build_config.h"
|
||||||
|
#include "cef/libcef/features/features.h"
|
||||||
|
|
||||||
|
// The following #defines are used in cef/include/ headers and CEF client-side
|
||||||
|
// code. CEF library-side code should use BUILDFLAG checks directly instead of
|
||||||
|
// these #defines. CEF client-side code will get these #defines from
|
||||||
|
// cef_config.h so any changes must also be reflected in
|
||||||
|
// tools/make_config_header.py.
|
||||||
|
|
||||||
|
#if BUILDFLAG(IS_LINUX)
|
||||||
|
#include "ui/base/ozone_buildflags.h"
|
||||||
|
#if BUILDFLAG(IS_OZONE_X11)
|
||||||
|
#define CEF_X11 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
|
#include "include/cef_config.h"
|
||||||
|
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#if defined(_WIN32)
|
// A set of macros to use for platform detection.
|
||||||
#ifndef OS_WIN
|
#if defined(ANDROID)
|
||||||
#define OS_WIN 1
|
#define OS_ANDROID 1
|
||||||
#endif
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#ifndef OS_MACOSX
|
// Only include TargetConditionals after testing ANDROID as some Android builds
|
||||||
#define OS_MACOSX 1
|
// on the Mac have this header available and it's not needed unless the target
|
||||||
#endif
|
// is really an Apple platform.
|
||||||
#elif defined(__linux__)
|
#include <TargetConditionals.h>
|
||||||
#ifndef OS_LINUX
|
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||||
#define OS_LINUX 1
|
#define OS_IOS 1
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#error Please add support for your platform in cef_build.h
|
#define OS_MAC 1
|
||||||
|
// For backwards compatibility.
|
||||||
|
#define OS_MACOSX 1
|
||||||
|
#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||||
|
#elif defined(__linux__)
|
||||||
|
#if !defined(OS_CHROMEOS)
|
||||||
|
// Do not define OS_LINUX on Chrome OS build.
|
||||||
|
// The OS_CHROMEOS macro is defined in GN.
|
||||||
|
#define OS_LINUX 1
|
||||||
|
#endif // !defined(OS_CHROMEOS)
|
||||||
|
// Include a system header to pull in features.h for glibc/uclibc macros.
|
||||||
|
#include <unistd.h>
|
||||||
|
#if defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||||
|
// We really are using glibc, not uClibc pretending to be glibc.
|
||||||
|
#define LIBC_GLIBC 1
|
||||||
|
#endif
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
#define OS_WIN 1
|
||||||
|
#elif defined(__Fuchsia__)
|
||||||
|
#define OS_FUCHSIA 1
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
#define OS_FREEBSD 1
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
#define OS_NETBSD 1
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
#define OS_OPENBSD 1
|
||||||
|
#elif defined(__sun)
|
||||||
|
#define OS_SOLARIS 1
|
||||||
|
#elif defined(__QNXNTO__)
|
||||||
|
#define OS_QNX 1
|
||||||
|
#elif defined(_AIX)
|
||||||
|
#define OS_AIX 1
|
||||||
|
#elif defined(__asmjs__) || defined(__wasm__)
|
||||||
|
#define OS_ASMJS 1
|
||||||
|
#else
|
||||||
|
#error Please add support for your platform in include/base/cef_build.h
|
||||||
|
#endif
|
||||||
|
// NOTE: Adding a new port? Please follow
|
||||||
|
// https://chromium.googlesource.com/chromium/src/+/master/docs/new_port_policy.md
|
||||||
|
|
||||||
|
#if defined(OS_MAC) || defined(OS_IOS)
|
||||||
|
#define OS_APPLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For access to standard BSD features, use OS_BSD instead of a
|
||||||
|
// more specific macro.
|
||||||
|
#if defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(OS_OPENBSD)
|
||||||
|
#define OS_BSD 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For access to standard POSIXish features, use OS_POSIX instead of a
|
// For access to standard POSIXish features, use OS_POSIX instead of a
|
||||||
// more specific macro.
|
// more specific macro.
|
||||||
#if defined(OS_MACOSX) || defined(OS_LINUX)
|
#if defined(OS_AIX) || defined(OS_ANDROID) || defined(OS_ASMJS) || \
|
||||||
#ifndef OS_POSIX
|
defined(OS_FREEBSD) || defined(OS_IOS) || defined(OS_LINUX) || \
|
||||||
|
defined(OS_CHROMEOS) || defined(OS_MAC) || defined(OS_NACL) || \
|
||||||
|
defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_QNX) || \
|
||||||
|
defined(OS_SOLARIS)
|
||||||
#define OS_POSIX 1
|
#define OS_POSIX 1
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
// Compiler detection.
|
// Compiler detection. Note: clang masquerades as GCC on POSIX and as MSVC on
|
||||||
|
// Windows.
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#ifndef COMPILER_GCC
|
|
||||||
#define COMPILER_GCC 1
|
#define COMPILER_GCC 1
|
||||||
#endif
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#ifndef COMPILER_MSVC
|
|
||||||
#define COMPILER_MSVC 1
|
#define COMPILER_MSVC 1
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#error Please add support for your compiler in cef_build.h
|
#error Please add support for your compiler in build/build_config.h
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Processor architecture detection. For more info on what's defined, see:
|
// Processor architecture detection. For more info on what's defined, see:
|
||||||
@@ -90,118 +186,95 @@
|
|||||||
#define ARCH_CPU_X86 1
|
#define ARCH_CPU_X86 1
|
||||||
#define ARCH_CPU_32_BITS 1
|
#define ARCH_CPU_32_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
|
#elif defined(__s390x__)
|
||||||
|
#define ARCH_CPU_S390_FAMILY 1
|
||||||
|
#define ARCH_CPU_S390X 1
|
||||||
|
#define ARCH_CPU_64_BITS 1
|
||||||
|
#define ARCH_CPU_BIG_ENDIAN 1
|
||||||
|
#elif defined(__s390__)
|
||||||
|
#define ARCH_CPU_S390_FAMILY 1
|
||||||
|
#define ARCH_CPU_S390 1
|
||||||
|
#define ARCH_CPU_31_BITS 1
|
||||||
|
#define ARCH_CPU_BIG_ENDIAN 1
|
||||||
|
#elif (defined(__PPC64__) || defined(__PPC__)) && defined(__BIG_ENDIAN__)
|
||||||
|
#define ARCH_CPU_PPC64_FAMILY 1
|
||||||
|
#define ARCH_CPU_PPC64 1
|
||||||
|
#define ARCH_CPU_64_BITS 1
|
||||||
|
#define ARCH_CPU_BIG_ENDIAN 1
|
||||||
|
#elif defined(__PPC64__)
|
||||||
|
#define ARCH_CPU_PPC64_FAMILY 1
|
||||||
|
#define ARCH_CPU_PPC64 1
|
||||||
|
#define ARCH_CPU_64_BITS 1
|
||||||
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
#elif defined(__ARMEL__)
|
#elif defined(__ARMEL__)
|
||||||
#define ARCH_CPU_ARM_FAMILY 1
|
#define ARCH_CPU_ARM_FAMILY 1
|
||||||
#define ARCH_CPU_ARMEL 1
|
#define ARCH_CPU_ARMEL 1
|
||||||
#define ARCH_CPU_32_BITS 1
|
#define ARCH_CPU_32_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||||
#define ARCH_CPU_ARM_FAMILY 1
|
#define ARCH_CPU_ARM_FAMILY 1
|
||||||
#define ARCH_CPU_ARM64 1
|
#define ARCH_CPU_ARM64 1
|
||||||
#define ARCH_CPU_64_BITS 1
|
#define ARCH_CPU_64_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
#elif defined(__pnacl__)
|
#elif defined(__pnacl__) || defined(__asmjs__) || defined(__wasm__)
|
||||||
#define ARCH_CPU_32_BITS 1
|
#define ARCH_CPU_32_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
#elif defined(__MIPSEL__)
|
#elif defined(__MIPSEL__)
|
||||||
|
#if defined(__LP64__)
|
||||||
|
#define ARCH_CPU_MIPS_FAMILY 1
|
||||||
|
#define ARCH_CPU_MIPS64EL 1
|
||||||
|
#define ARCH_CPU_64_BITS 1
|
||||||
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
|
#else
|
||||||
#define ARCH_CPU_MIPS_FAMILY 1
|
#define ARCH_CPU_MIPS_FAMILY 1
|
||||||
#define ARCH_CPU_MIPSEL 1
|
#define ARCH_CPU_MIPSEL 1
|
||||||
#define ARCH_CPU_32_BITS 1
|
#define ARCH_CPU_32_BITS 1
|
||||||
#define ARCH_CPU_LITTLE_ENDIAN 1
|
#define ARCH_CPU_LITTLE_ENDIAN 1
|
||||||
|
#endif
|
||||||
|
#elif defined(__MIPSEB__)
|
||||||
|
#if defined(__LP64__)
|
||||||
|
#define ARCH_CPU_MIPS_FAMILY 1
|
||||||
|
#define ARCH_CPU_MIPS64 1
|
||||||
|
#define ARCH_CPU_64_BITS 1
|
||||||
|
#define ARCH_CPU_BIG_ENDIAN 1
|
||||||
#else
|
#else
|
||||||
#error Please add support for your architecture in cef_build.h
|
#define ARCH_CPU_MIPS_FAMILY 1
|
||||||
|
#define ARCH_CPU_MIPS 1
|
||||||
|
#define ARCH_CPU_32_BITS 1
|
||||||
|
#define ARCH_CPU_BIG_ENDIAN 1
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#error Please add support for your architecture in include/base/cef_build.h
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Type detection for wchar_t.
|
// Type detection for wchar_t.
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#define WCHAR_T_IS_UTF16
|
#define WCHAR_T_IS_16_BIT
|
||||||
|
#elif defined(OS_FUCHSIA)
|
||||||
|
#define WCHAR_T_IS_32_BIT
|
||||||
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
||||||
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
|
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
|
||||||
#define WCHAR_T_IS_UTF32
|
#define WCHAR_T_IS_32_BIT
|
||||||
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
|
||||||
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
|
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
|
||||||
// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
|
// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
|
||||||
// compile in this mode (in particular, Chrome doesn't). This is intended for
|
// compile in this mode (in particular, Chrome doesn't). This is intended for
|
||||||
// other projects using base who manage their own dependencies and make sure
|
// other projects using base who manage their own dependencies and make sure
|
||||||
// short wchar works for them.
|
// short wchar works for them.
|
||||||
#define WCHAR_T_IS_UTF16
|
#define WCHAR_T_IS_16_BIT
|
||||||
#else
|
#else
|
||||||
#error Please add support for your compiler in cef_build.h
|
#error Please add support for your compiler in include/base/cef_build.h
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Annotate a function indicating the caller must examine the return value.
|
#if defined(OS_ANDROID)
|
||||||
// Use like:
|
// The compiler thinks std::string::const_iterator and "const char*" are
|
||||||
// int foo() WARN_UNUSED_RESULT;
|
// equivalent types.
|
||||||
// To explicitly ignore a result, see |ignore_result()| in <base/macros.h>.
|
#define STD_STRING_ITERATOR_IS_CHAR_POINTER
|
||||||
#ifndef WARN_UNUSED_RESULT
|
// The compiler thinks std::u16string::const_iterator and "char16_t*" are
|
||||||
#if defined(COMPILER_GCC)
|
// equivalent types.
|
||||||
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
|
||||||
#else
|
|
||||||
#define WARN_UNUSED_RESULT
|
|
||||||
#endif
|
|
||||||
#endif // WARN_UNUSED_RESULT
|
|
||||||
|
|
||||||
// Annotate a typedef or function indicating it's ok if it's not used.
|
|
||||||
// Use like:
|
|
||||||
// typedef Foo Bar ALLOW_UNUSED_TYPE;
|
|
||||||
#ifndef ALLOW_UNUSED_TYPE
|
|
||||||
#if defined(COMPILER_GCC)
|
|
||||||
#define ALLOW_UNUSED_TYPE __attribute__((unused))
|
|
||||||
#else
|
|
||||||
#define ALLOW_UNUSED_TYPE
|
|
||||||
#endif
|
|
||||||
#endif // ALLOW_UNUSED_TYPE
|
|
||||||
|
|
||||||
// Annotate a variable indicating it's ok if the variable is not used.
|
|
||||||
// (Typically used to silence a compiler warning when the assignment
|
|
||||||
// is important for some other reason.)
|
|
||||||
// Use like:
|
|
||||||
// int x = ...;
|
|
||||||
// ALLOW_UNUSED_LOCAL(x);
|
|
||||||
#ifndef ALLOW_UNUSED_LOCAL
|
|
||||||
#define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Sanitizers annotations.
|
|
||||||
#if defined(__has_attribute)
|
|
||||||
#if __has_attribute(no_sanitize)
|
|
||||||
#define NO_SANITIZE(what) __attribute__((no_sanitize(what)))
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !defined(NO_SANITIZE)
|
|
||||||
#define NO_SANITIZE(what)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
// Annotate a virtual method indicating it must be overriding a virtual method
|
|
||||||
// in the parent class.
|
|
||||||
// Use like:
|
|
||||||
// void foo() OVERRIDE;
|
|
||||||
// NOTE: This define should only be used in classes exposed to the client since
|
|
||||||
// C++11 support may not be enabled in client applications. CEF internal classes
|
|
||||||
// should use the `override` keyword directly.
|
|
||||||
#ifndef OVERRIDE
|
|
||||||
#if defined(__clang__)
|
|
||||||
#define OVERRIDE override
|
|
||||||
#elif defined(COMPILER_MSVC) && _MSC_VER >= 1600
|
|
||||||
// Visual Studio 2010 and later support override.
|
|
||||||
#define OVERRIDE override
|
|
||||||
#elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \
|
|
||||||
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
|
|
||||||
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
|
|
||||||
#define OVERRIDE override
|
|
||||||
#else
|
|
||||||
#define OVERRIDE
|
|
||||||
#endif
|
|
||||||
#endif // OVERRIDE
|
|
||||||
|
|
||||||
// Check for C++11 template alias support which was added in VS2013 and GCC4.7.
|
|
||||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
|
|
||||||
#if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1800) || \
|
|
||||||
(defined(__GNUC__) && \
|
|
||||||
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700))
|
|
||||||
#define HAS_CPP11_TEMPLATE_ALIAS_SUPPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_
|
#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_
|
||||||
|
|||||||
@@ -28,772 +28,221 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
/// \file
|
||||||
|
/// A callback is similar in concept to a function pointer: it wraps a runnable
|
||||||
|
/// object such as a function, method, lambda, or even another callback,
|
||||||
|
/// allowing the runnable object to be invoked later via the callback object.
|
||||||
|
///
|
||||||
|
/// Unlike function pointers, callbacks are created with base::BindOnce() or
|
||||||
|
/// base::BindRepeating() and support partial function application.
|
||||||
|
///
|
||||||
|
/// A base::OnceCallback may be Run() at most once; a base::RepeatingCallback
|
||||||
|
/// may be Run() any number of times. |is_null()| is guaranteed to return true
|
||||||
|
/// for a moved-from callback.
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// // The lambda takes two arguments, but the first argument |x| is bound at
|
||||||
|
/// // callback creation.
|
||||||
|
/// base::OnceCallback<int(int)> cb = base::BindOnce([] (int x, int y) {
|
||||||
|
/// return x + y;
|
||||||
|
/// }, 1);
|
||||||
|
/// // Run() only needs the remaining unbound argument |y|.
|
||||||
|
/// printf("1 + 2 = %d\n", std::move(cb).Run(2)); // Prints 3
|
||||||
|
/// printf("cb is null? %s\n",
|
||||||
|
/// cb.is_null() ? "true" : "false"); // Prints true
|
||||||
|
/// std::move(cb).Run(2); // Crashes since |cb| has already run.
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// Callbacks also support cancellation. A common use is binding the receiver
|
||||||
|
/// object as a WeakPtr<T>. If that weak pointer is invalidated, calling Run()
|
||||||
|
/// will be a no-op. Note that |IsCancelled()| and |is_null()| are distinct:
|
||||||
|
/// simply cancelling a callback will not also make it null.
|
||||||
|
///
|
||||||
|
/// See https://chromium.googlesource.com/chromium/src/+/lkgr/docs/callback.md
|
||||||
|
/// for the full documentation.
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
#define CEF_INCLUDE_BASE_CEF_CALLBACK_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_CALLBACK_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/callback.h"
|
#include "base/functional/callback.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "include/base/cef_bind.h"
|
||||||
#include "include/base/cef_callback_forward.h"
|
#include "include/base/cef_callback_forward.h"
|
||||||
#include "include/base/cef_template_util.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/internal/cef_callback_internal.h"
|
#include "include/base/internal/cef_callback_internal.h"
|
||||||
|
|
||||||
// NOTE: Header files that do not require the full definition of Callback or
|
|
||||||
// Closure should #include "base/cef_callback_forward.h" instead of this file.
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Introduction
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// The templated Callback class is a generalized function object. Together
|
|
||||||
// with the Bind() function in bind.h, they provide a type-safe method for
|
|
||||||
// performing partial application of functions.
|
|
||||||
//
|
|
||||||
// Partial application (or "currying") is the process of binding a subset of
|
|
||||||
// a function's arguments to produce another function that takes fewer
|
|
||||||
// arguments. This can be used to pass around a unit of delayed execution,
|
|
||||||
// much like lexical closures are used in other languages. For example, it
|
|
||||||
// is used in Chromium code to schedule tasks on different MessageLoops.
|
|
||||||
//
|
|
||||||
// A callback with no unbound input parameters (base::Callback<void(void)>)
|
|
||||||
// is called a base::Closure. Note that this is NOT the same as what other
|
|
||||||
// languages refer to as a closure -- it does not retain a reference to its
|
|
||||||
// enclosing environment.
|
|
||||||
//
|
|
||||||
// MEMORY MANAGEMENT AND PASSING
|
|
||||||
//
|
|
||||||
// The Callback objects themselves should be passed by const-reference, and
|
|
||||||
// stored by copy. They internally store their state via a refcounted class
|
|
||||||
// and thus do not need to be deleted.
|
|
||||||
//
|
|
||||||
// The reason to pass via a const-reference is to avoid unnecessary
|
|
||||||
// AddRef/Release pairs to the internal state.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Quick reference for basic stuff
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// BINDING A BARE FUNCTION
|
|
||||||
//
|
|
||||||
// int Return5() { return 5; }
|
|
||||||
// base::Callback<int(void)> func_cb = base::Bind(&Return5);
|
|
||||||
// LOG(INFO) << func_cb.Run(); // Prints 5.
|
|
||||||
//
|
|
||||||
// BINDING A CLASS METHOD
|
|
||||||
//
|
|
||||||
// The first argument to bind is the member function to call, the second is
|
|
||||||
// the object on which to call it.
|
|
||||||
//
|
|
||||||
// class Ref : public base::RefCountedThreadSafe<Ref> {
|
|
||||||
// public:
|
|
||||||
// int Foo() { return 3; }
|
|
||||||
// void PrintBye() { LOG(INFO) << "bye."; }
|
|
||||||
// };
|
|
||||||
// scoped_refptr<Ref> ref = new Ref();
|
|
||||||
// base::Callback<void(void)> ref_cb = base::Bind(&Ref::Foo, ref);
|
|
||||||
// LOG(INFO) << ref_cb.Run(); // Prints out 3.
|
|
||||||
//
|
|
||||||
// By default the object must support RefCounted or you will get a compiler
|
|
||||||
// error. If you're passing between threads, be sure it's
|
|
||||||
// RefCountedThreadSafe! See "Advanced binding of member functions" below if
|
|
||||||
// you don't want to use reference counting.
|
|
||||||
//
|
|
||||||
// RUNNING A CALLBACK
|
|
||||||
//
|
|
||||||
// Callbacks can be run with their "Run" method, which has the same
|
|
||||||
// signature as the template argument to the callback.
|
|
||||||
//
|
|
||||||
// void DoSomething(const base::Callback<void(int, std::string)>& callback) {
|
|
||||||
// callback.Run(5, "hello");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Callbacks can be run more than once (they don't get deleted or marked when
|
|
||||||
// run). However, this precludes using base::Passed (see below).
|
|
||||||
//
|
|
||||||
// void DoSomething(const base::Callback<double(double)>& callback) {
|
|
||||||
// double myresult = callback.Run(3.14159);
|
|
||||||
// myresult += callback.Run(2.71828);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// PASSING UNBOUND INPUT PARAMETERS
|
|
||||||
//
|
|
||||||
// Unbound parameters are specified at the time a callback is Run(). They are
|
|
||||||
// specified in the Callback template type:
|
|
||||||
//
|
|
||||||
// void MyFunc(int i, const std::string& str) {}
|
|
||||||
// base::Callback<void(int, const std::string&)> cb = base::Bind(&MyFunc);
|
|
||||||
// cb.Run(23, "hello, world");
|
|
||||||
//
|
|
||||||
// PASSING BOUND INPUT PARAMETERS
|
|
||||||
//
|
|
||||||
// Bound parameters are specified when you create thee callback as arguments
|
|
||||||
// to Bind(). They will be passed to the function and the Run()ner of the
|
|
||||||
// callback doesn't see those values or even know that the function it's
|
|
||||||
// calling.
|
|
||||||
//
|
|
||||||
// void MyFunc(int i, const std::string& str) {}
|
|
||||||
// base::Callback<void(void)> cb = base::Bind(&MyFunc, 23, "hello world");
|
|
||||||
// cb.Run();
|
|
||||||
//
|
|
||||||
// A callback with no unbound input parameters (base::Callback<void(void)>)
|
|
||||||
// is called a base::Closure. So we could have also written:
|
|
||||||
//
|
|
||||||
// base::Closure cb = base::Bind(&MyFunc, 23, "hello world");
|
|
||||||
//
|
|
||||||
// When calling member functions, bound parameters just go after the object
|
|
||||||
// pointer.
|
|
||||||
//
|
|
||||||
// base::Closure cb = base::Bind(&MyClass::MyFunc, this, 23, "hello world");
|
|
||||||
//
|
|
||||||
// PARTIAL BINDING OF PARAMETERS
|
|
||||||
//
|
|
||||||
// You can specify some parameters when you create the callback, and specify
|
|
||||||
// the rest when you execute the callback.
|
|
||||||
//
|
|
||||||
// void MyFunc(int i, const std::string& str) {}
|
|
||||||
// base::Callback<void(const std::string&)> cb = base::Bind(&MyFunc, 23);
|
|
||||||
// cb.Run("hello world");
|
|
||||||
//
|
|
||||||
// When calling a function bound parameters are first, followed by unbound
|
|
||||||
// parameters.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Quick reference for advanced binding
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// BINDING A CLASS METHOD WITH WEAK POINTERS
|
|
||||||
//
|
|
||||||
// base::Bind(&MyClass::Foo, GetWeakPtr());
|
|
||||||
//
|
|
||||||
// The callback will not be run if the object has already been destroyed.
|
|
||||||
// DANGER: weak pointers are not threadsafe, so don't use this
|
|
||||||
// when passing between threads!
|
|
||||||
//
|
|
||||||
// BINDING A CLASS METHOD WITH MANUAL LIFETIME MANAGEMENT
|
|
||||||
//
|
|
||||||
// base::Bind(&MyClass::Foo, base::Unretained(this));
|
|
||||||
//
|
|
||||||
// This disables all lifetime management on the object. You're responsible
|
|
||||||
// for making sure the object is alive at the time of the call. You break it,
|
|
||||||
// you own it!
|
|
||||||
//
|
|
||||||
// BINDING A CLASS METHOD AND HAVING THE CALLBACK OWN THE CLASS
|
|
||||||
//
|
|
||||||
// MyClass* myclass = new MyClass;
|
|
||||||
// base::Bind(&MyClass::Foo, base::Owned(myclass));
|
|
||||||
//
|
|
||||||
// The object will be deleted when the callback is destroyed, even if it's
|
|
||||||
// not run (like if you post a task during shutdown). Potentially useful for
|
|
||||||
// "fire and forget" cases.
|
|
||||||
//
|
|
||||||
// IGNORING RETURN VALUES
|
|
||||||
//
|
|
||||||
// Sometimes you want to call a function that returns a value in a callback
|
|
||||||
// that doesn't expect a return value.
|
|
||||||
//
|
|
||||||
// int DoSomething(int arg) { cout << arg << endl; }
|
|
||||||
// base::Callback<void<int>) cb =
|
|
||||||
// base::Bind(base::IgnoreResult(&DoSomething));
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Quick reference for binding parameters to Bind()
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Bound parameters are specified as arguments to Bind() and are passed to the
|
|
||||||
// function. A callback with no parameters or no unbound parameters is called a
|
|
||||||
// Closure (base::Callback<void(void)> and base::Closure are the same thing).
|
|
||||||
//
|
|
||||||
// PASSING PARAMETERS OWNED BY THE CALLBACK
|
|
||||||
//
|
|
||||||
// void Foo(int* arg) { cout << *arg << endl; }
|
|
||||||
// int* pn = new int(1);
|
|
||||||
// base::Closure foo_callback = base::Bind(&foo, base::Owned(pn));
|
|
||||||
//
|
|
||||||
// The parameter will be deleted when the callback is destroyed, even if it's
|
|
||||||
// not run (like if you post a task during shutdown).
|
|
||||||
//
|
|
||||||
// PASSING PARAMETERS AS A scoped_ptr
|
|
||||||
//
|
|
||||||
// void TakesOwnership(scoped_ptr<Foo> arg) {}
|
|
||||||
// scoped_ptr<Foo> f(new Foo);
|
|
||||||
// // f becomes null during the following call.
|
|
||||||
// base::Closure cb = base::Bind(&TakesOwnership, base::Passed(&f));
|
|
||||||
//
|
|
||||||
// Ownership of the parameter will be with the callback until the it is run,
|
|
||||||
// when ownership is passed to the callback function. This means the callback
|
|
||||||
// can only be run once. If the callback is never run, it will delete the
|
|
||||||
// object when it's destroyed.
|
|
||||||
//
|
|
||||||
// PASSING PARAMETERS AS A scoped_refptr
|
|
||||||
//
|
|
||||||
// void TakesOneRef(scoped_refptr<Foo> arg) {}
|
|
||||||
// scoped_refptr<Foo> f(new Foo)
|
|
||||||
// base::Closure cb = base::Bind(&TakesOneRef, f);
|
|
||||||
//
|
|
||||||
// This should "just work." The closure will take a reference as long as it
|
|
||||||
// is alive, and another reference will be taken for the called function.
|
|
||||||
//
|
|
||||||
// PASSING PARAMETERS BY REFERENCE
|
|
||||||
//
|
|
||||||
// Const references are *copied* unless ConstRef is used. Example:
|
|
||||||
//
|
|
||||||
// void foo(const int& arg) { printf("%d %p\n", arg, &arg); }
|
|
||||||
// int n = 1;
|
|
||||||
// base::Closure has_copy = base::Bind(&foo, n);
|
|
||||||
// base::Closure has_ref = base::Bind(&foo, base::ConstRef(n));
|
|
||||||
// n = 2;
|
|
||||||
// foo(n); // Prints "2 0xaaaaaaaaaaaa"
|
|
||||||
// has_copy.Run(); // Prints "1 0xbbbbbbbbbbbb"
|
|
||||||
// has_ref.Run(); // Prints "2 0xaaaaaaaaaaaa"
|
|
||||||
//
|
|
||||||
// Normally parameters are copied in the closure. DANGER: ConstRef stores a
|
|
||||||
// const reference instead, referencing the original parameter. This means
|
|
||||||
// that you must ensure the object outlives the callback!
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// Implementation notes
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// WHERE IS THIS DESIGN FROM:
|
|
||||||
//
|
|
||||||
// The design Callback and Bind is heavily influenced by C++'s
|
|
||||||
// tr1::function/tr1::bind, and by the "Google Callback" system used inside
|
|
||||||
// Google.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// HOW THE IMPLEMENTATION WORKS:
|
|
||||||
//
|
|
||||||
// There are three main components to the system:
|
|
||||||
// 1) The Callback classes.
|
|
||||||
// 2) The Bind() functions.
|
|
||||||
// 3) The arguments wrappers (e.g., Unretained() and ConstRef()).
|
|
||||||
//
|
|
||||||
// The Callback classes represent a generic function pointer. Internally,
|
|
||||||
// it stores a refcounted piece of state that represents the target function
|
|
||||||
// and all its bound parameters. Each Callback specialization has a templated
|
|
||||||
// constructor that takes an BindState<>*. In the context of the constructor,
|
|
||||||
// the static type of this BindState<> pointer uniquely identifies the
|
|
||||||
// function it is representing, all its bound parameters, and a Run() method
|
|
||||||
// that is capable of invoking the target.
|
|
||||||
//
|
|
||||||
// Callback's constructor takes the BindState<>* that has the full static type
|
|
||||||
// and erases the target function type as well as the types of the bound
|
|
||||||
// parameters. It does this by storing a pointer to the specific Run()
|
|
||||||
// function, and upcasting the state of BindState<>* to a
|
|
||||||
// BindStateBase*. This is safe as long as this BindStateBase pointer
|
|
||||||
// is only used with the stored Run() pointer.
|
|
||||||
//
|
|
||||||
// To BindState<> objects are created inside the Bind() functions.
|
|
||||||
// These functions, along with a set of internal templates, are responsible for
|
|
||||||
//
|
|
||||||
// - Unwrapping the function signature into return type, and parameters
|
|
||||||
// - Determining the number of parameters that are bound
|
|
||||||
// - Creating the BindState storing the bound parameters
|
|
||||||
// - Performing compile-time asserts to avoid error-prone behavior
|
|
||||||
// - Returning an Callback<> with an arity matching the number of unbound
|
|
||||||
// parameters and that knows the correct refcounting semantics for the
|
|
||||||
// target object if we are binding a method.
|
|
||||||
//
|
|
||||||
// The Bind functions do the above using type-inference, and template
|
|
||||||
// specializations.
|
|
||||||
//
|
|
||||||
// By default Bind() will store copies of all bound parameters, and attempt
|
|
||||||
// to refcount a target object if the function being bound is a class method.
|
|
||||||
// These copies are created even if the function takes parameters as const
|
|
||||||
// references. (Binding to non-const references is forbidden, see bind.h.)
|
|
||||||
//
|
|
||||||
// To change this behavior, we introduce a set of argument wrappers
|
|
||||||
// (e.g., Unretained(), and ConstRef()). These are simple container templates
|
|
||||||
// that are passed by value, and wrap a pointer to argument. See the
|
|
||||||
// file-level comment in base/bind_helpers.h for more info.
|
|
||||||
//
|
|
||||||
// These types are passed to the Unwrap() functions, and the MaybeRefcount()
|
|
||||||
// functions respectively to modify the behavior of Bind(). The Unwrap()
|
|
||||||
// and MaybeRefcount() functions change behavior by doing partial
|
|
||||||
// specialization based on whether or not a parameter is a wrapper type.
|
|
||||||
//
|
|
||||||
// ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// WHY NOT TR1 FUNCTION/BIND?
|
|
||||||
//
|
|
||||||
// Direct use of tr1::function and tr1::bind was considered, but ultimately
|
|
||||||
// rejected because of the number of copy constructors invocations involved
|
|
||||||
// in the binding of arguments during construction, and the forwarding of
|
|
||||||
// arguments during invocation. These copies will no longer be an issue in
|
|
||||||
// C++0x because C++0x will support rvalue reference allowing for the compiler
|
|
||||||
// to avoid these copies. However, waiting for C++0x is not an option.
|
|
||||||
//
|
|
||||||
// Measured with valgrind on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5), the
|
|
||||||
// tr1::bind call itself will invoke a non-trivial copy constructor three times
|
|
||||||
// for each bound parameter. Also, each when passing a tr1::function, each
|
|
||||||
// bound argument will be copied again.
|
|
||||||
//
|
|
||||||
// In addition to the copies taken at binding and invocation, copying a
|
|
||||||
// tr1::function causes a copy to be made of all the bound parameters and
|
|
||||||
// state.
|
|
||||||
//
|
|
||||||
// Furthermore, in Chromium, it is desirable for the Callback to take a
|
|
||||||
// reference on a target object when representing a class method call. This
|
|
||||||
// is not supported by tr1.
|
|
||||||
//
|
|
||||||
// Lastly, tr1::function and tr1::bind has a more general and flexible API.
|
|
||||||
// This includes things like argument reordering by use of
|
|
||||||
// tr1::bind::placeholder, support for non-const reference parameters, and some
|
|
||||||
// limited amount of subtyping of the tr1::function object (e.g.,
|
|
||||||
// tr1::function<int(int)> is convertible to tr1::function<void(int)>).
|
|
||||||
//
|
|
||||||
// These are not features that are required in Chromium. Some of them, such as
|
|
||||||
// allowing for reference parameters, and subtyping of functions, may actually
|
|
||||||
// become a source of errors. Removing support for these features actually
|
|
||||||
// allows for a simpler implementation, and a terser Currying API.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// WHY NOT GOOGLE CALLBACKS?
|
|
||||||
//
|
|
||||||
// The Google callback system also does not support refcounting. Furthermore,
|
|
||||||
// its implementation has a number of strange edge cases with respect to type
|
|
||||||
// conversion of its arguments. In particular, the argument's constness must
|
|
||||||
// at times match exactly the function signature, or the type-inference might
|
|
||||||
// break. Given the above, writing a custom solution was easier.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// MISSING FUNCTIONALITY
|
|
||||||
// - Invoking the return of Bind. Bind(&foo).Run() does not work;
|
|
||||||
// - Binding arrays to functions that take a non-const pointer.
|
|
||||||
// Example:
|
|
||||||
// void Foo(const char* ptr);
|
|
||||||
// void Bar(char* ptr);
|
|
||||||
// Bind(&Foo, "test");
|
|
||||||
// Bind(&Bar, "test"); // This fails because ptr is not const.
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
// First, we forward declare the Callback class template. This informs the
|
template <typename R, typename... Args>
|
||||||
// compiler that the template only has 1 type parameter which is the function
|
class OnceCallback<R(Args...)> : public cef_internal::CallbackBase {
|
||||||
// signature that the Callback is representing.
|
|
||||||
//
|
|
||||||
// After this, create template specializations for 0-7 parameters. Note that
|
|
||||||
// even though the template typelist grows, the specialization still
|
|
||||||
// only has one type: the function signature.
|
|
||||||
//
|
|
||||||
// If you are thinking of forward declaring Callback in your own header file,
|
|
||||||
// please include "base/callback_forward.h" instead.
|
|
||||||
template <typename Sig>
|
|
||||||
class Callback;
|
|
||||||
|
|
||||||
namespace cef_internal {
|
|
||||||
template <typename Runnable, typename RunType, typename BoundArgsType>
|
|
||||||
struct BindState;
|
|
||||||
} // namespace cef_internal
|
|
||||||
|
|
||||||
template <typename R>
|
|
||||||
class Callback<R(void)> : public cef_internal::CallbackBase {
|
|
||||||
public:
|
public:
|
||||||
typedef R(RunType)();
|
using ResultType = R;
|
||||||
|
using RunType = R(Args...);
|
||||||
|
using PolymorphicInvoke = R (*)(cef_internal::BindStateBase*,
|
||||||
|
cef_internal::PassingType<Args>...);
|
||||||
|
|
||||||
Callback() : CallbackBase(NULL) {}
|
constexpr OnceCallback() = default;
|
||||||
|
OnceCallback(std::nullptr_t) = delete;
|
||||||
|
|
||||||
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
explicit OnceCallback(cef_internal::BindStateBase* bind_state)
|
||||||
// return the exact Callback<> type. See base/bind.h for details.
|
: cef_internal::CallbackBase(bind_state) {}
|
||||||
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
|
||||||
Callback(
|
OnceCallback(const OnceCallback&) = delete;
|
||||||
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
|
OnceCallback& operator=(const OnceCallback&) = delete;
|
||||||
: CallbackBase(bind_state) {
|
|
||||||
// Force the assignment to a local variable of PolymorphicInvoke
|
OnceCallback(OnceCallback&&) noexcept = default;
|
||||||
// so the compiler will typecheck that the passed in Run() method has
|
OnceCallback& operator=(OnceCallback&&) noexcept = default;
|
||||||
// the correct type.
|
|
||||||
PolymorphicInvoke invoke_func =
|
OnceCallback(RepeatingCallback<RunType> other)
|
||||||
&cef_internal::BindState<Runnable, BindRunType,
|
: cef_internal::CallbackBase(std::move(other)) {}
|
||||||
BoundArgsType>::InvokerType::Run;
|
|
||||||
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
OnceCallback& operator=(RepeatingCallback<RunType> other) {
|
||||||
|
static_cast<cef_internal::CallbackBase&>(*this) = std::move(other);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Equals(const Callback& other) const {
|
R Run(Args... args) const& {
|
||||||
return CallbackBase::Equals(other);
|
static_assert(!sizeof(*this),
|
||||||
|
"OnceCallback::Run() may only be invoked on a non-const "
|
||||||
|
"rvalue, i.e. std::move(callback).Run().");
|
||||||
|
NOTREACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
R Run() const {
|
R Run(Args... args) && {
|
||||||
|
// Move the callback instance into a local variable before the invocation,
|
||||||
|
// that ensures the internal state is cleared after the invocation.
|
||||||
|
// It's not safe to touch |this| after the invocation, since running the
|
||||||
|
// bound function may destroy |this|.
|
||||||
|
OnceCallback cb = std::move(*this);
|
||||||
PolymorphicInvoke f =
|
PolymorphicInvoke f =
|
||||||
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
reinterpret_cast<PolymorphicInvoke>(cb.polymorphic_invoke());
|
||||||
|
return f(cb.bind_state_.get(), std::forward<Args>(args)...);
|
||||||
return f(bind_state_.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
// Then() returns a new OnceCallback that receives the same arguments as
|
||||||
typedef R (*PolymorphicInvoke)(cef_internal::BindStateBase*);
|
// |this|, and with the return type of |then|. The returned callback will:
|
||||||
|
// 1) Run the functor currently bound to |this| callback.
|
||||||
|
// 2) Run the |then| callback with the result from step 1 as its single
|
||||||
|
// argument.
|
||||||
|
// 3) Return the value from running the |then| callback.
|
||||||
|
//
|
||||||
|
// Since this method generates a callback that is a replacement for `this`,
|
||||||
|
// `this` will be consumed and reset to a null callback to ensure the
|
||||||
|
// originally-bound functor can be run at most once.
|
||||||
|
template <typename ThenR, typename... ThenArgs>
|
||||||
|
OnceCallback<ThenR(Args...)> Then(OnceCallback<ThenR(ThenArgs...)> then) && {
|
||||||
|
CHECK(then);
|
||||||
|
return BindOnce(
|
||||||
|
cef_internal::ThenHelper<
|
||||||
|
OnceCallback, OnceCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||||
|
std::move(*this), std::move(then));
|
||||||
|
}
|
||||||
|
|
||||||
|
// This overload is required; even though RepeatingCallback is implicitly
|
||||||
|
// convertible to OnceCallback, that conversion will not used when matching
|
||||||
|
// for template argument deduction.
|
||||||
|
template <typename ThenR, typename... ThenArgs>
|
||||||
|
OnceCallback<ThenR(Args...)> Then(
|
||||||
|
RepeatingCallback<ThenR(ThenArgs...)> then) && {
|
||||||
|
CHECK(then);
|
||||||
|
return BindOnce(
|
||||||
|
cef_internal::ThenHelper<
|
||||||
|
OnceCallback,
|
||||||
|
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||||
|
std::move(*this), std::move(then));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename R, typename A1>
|
template <typename R, typename... Args>
|
||||||
class Callback<R(A1)> : public cef_internal::CallbackBase {
|
class RepeatingCallback<R(Args...)>
|
||||||
|
: public cef_internal::CallbackBaseCopyable {
|
||||||
public:
|
public:
|
||||||
typedef R(RunType)(A1);
|
using ResultType = R;
|
||||||
|
using RunType = R(Args...);
|
||||||
|
using PolymorphicInvoke = R (*)(cef_internal::BindStateBase*,
|
||||||
|
cef_internal::PassingType<Args>...);
|
||||||
|
|
||||||
Callback() : CallbackBase(NULL) {}
|
constexpr RepeatingCallback() = default;
|
||||||
|
RepeatingCallback(std::nullptr_t) = delete;
|
||||||
|
|
||||||
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
explicit RepeatingCallback(cef_internal::BindStateBase* bind_state)
|
||||||
// return the exact Callback<> type. See base/bind.h for details.
|
: cef_internal::CallbackBaseCopyable(bind_state) {}
|
||||||
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
|
||||||
Callback(
|
// Copyable and movable.
|
||||||
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
|
RepeatingCallback(const RepeatingCallback&) = default;
|
||||||
: CallbackBase(bind_state) {
|
RepeatingCallback& operator=(const RepeatingCallback&) = default;
|
||||||
// Force the assignment to a local variable of PolymorphicInvoke
|
RepeatingCallback(RepeatingCallback&&) noexcept = default;
|
||||||
// so the compiler will typecheck that the passed in Run() method has
|
RepeatingCallback& operator=(RepeatingCallback&&) noexcept = default;
|
||||||
// the correct type.
|
|
||||||
PolymorphicInvoke invoke_func =
|
bool operator==(const RepeatingCallback& other) const {
|
||||||
&cef_internal::BindState<Runnable, BindRunType,
|
return EqualsInternal(other);
|
||||||
BoundArgsType>::InvokerType::Run;
|
|
||||||
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Equals(const Callback& other) const {
|
bool operator!=(const RepeatingCallback& other) const {
|
||||||
return CallbackBase::Equals(other);
|
return !operator==(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1) const {
|
R Run(Args... args) const& {
|
||||||
PolymorphicInvoke f =
|
PolymorphicInvoke f =
|
||||||
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
reinterpret_cast<PolymorphicInvoke>(this->polymorphic_invoke());
|
||||||
|
return f(this->bind_state_.get(), std::forward<Args>(args)...);
|
||||||
return f(bind_state_.get(), cef_internal::CallbackForward(a1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
R Run(Args... args) && {
|
||||||
typedef R (*PolymorphicInvoke)(
|
// Move the callback instance into a local variable before the invocation,
|
||||||
cef_internal::BindStateBase*,
|
// that ensures the internal state is cleared after the invocation.
|
||||||
typename cef_internal::CallbackParamTraits<A1>::ForwardType);
|
// It's not safe to touch |this| after the invocation, since running the
|
||||||
};
|
// bound function may destroy |this|.
|
||||||
|
RepeatingCallback cb = std::move(*this);
|
||||||
template <typename R, typename A1, typename A2>
|
|
||||||
class Callback<R(A1, A2)> : public cef_internal::CallbackBase {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2);
|
|
||||||
|
|
||||||
Callback() : CallbackBase(NULL) {}
|
|
||||||
|
|
||||||
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
|
||||||
// return the exact Callback<> type. See base/bind.h for details.
|
|
||||||
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
|
||||||
Callback(
|
|
||||||
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
|
|
||||||
: CallbackBase(bind_state) {
|
|
||||||
// Force the assignment to a local variable of PolymorphicInvoke
|
|
||||||
// so the compiler will typecheck that the passed in Run() method has
|
|
||||||
// the correct type.
|
|
||||||
PolymorphicInvoke invoke_func =
|
|
||||||
&cef_internal::BindState<Runnable, BindRunType,
|
|
||||||
BoundArgsType>::InvokerType::Run;
|
|
||||||
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Equals(const Callback& other) const {
|
|
||||||
return CallbackBase::Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2) const {
|
|
||||||
PolymorphicInvoke f =
|
PolymorphicInvoke f =
|
||||||
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
reinterpret_cast<PolymorphicInvoke>(cb.polymorphic_invoke());
|
||||||
|
return f(std::move(cb).bind_state_.get(), std::forward<Args>(args)...);
|
||||||
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
|
|
||||||
cef_internal::CallbackForward(a2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
// Then() returns a new RepeatingCallback that receives the same arguments as
|
||||||
typedef R (*PolymorphicInvoke)(
|
// |this|, and with the return type of |then|. The
|
||||||
cef_internal::BindStateBase*,
|
// returned callback will:
|
||||||
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
// 1) Run the functor currently bound to |this| callback.
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType);
|
// 2) Run the |then| callback with the result from step 1 as its single
|
||||||
|
// argument.
|
||||||
|
// 3) Return the value from running the |then| callback.
|
||||||
|
//
|
||||||
|
// If called on an rvalue (e.g. std::move(cb).Then(...)), this method
|
||||||
|
// generates a callback that is a replacement for `this`. Therefore, `this`
|
||||||
|
// will be consumed and reset to a null callback to ensure the
|
||||||
|
// originally-bound functor will be run at most once.
|
||||||
|
template <typename ThenR, typename... ThenArgs>
|
||||||
|
RepeatingCallback<ThenR(Args...)> Then(
|
||||||
|
RepeatingCallback<ThenR(ThenArgs...)> then) const& {
|
||||||
|
CHECK(then);
|
||||||
|
return BindRepeating(
|
||||||
|
cef_internal::ThenHelper<
|
||||||
|
RepeatingCallback,
|
||||||
|
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||||
|
*this, std::move(then));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ThenR, typename... ThenArgs>
|
||||||
|
RepeatingCallback<ThenR(Args...)> Then(
|
||||||
|
RepeatingCallback<ThenR(ThenArgs...)> then) && {
|
||||||
|
CHECK(then);
|
||||||
|
return BindRepeating(
|
||||||
|
cef_internal::ThenHelper<
|
||||||
|
RepeatingCallback,
|
||||||
|
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
|
||||||
|
std::move(*this), std::move(then));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3>
|
|
||||||
class Callback<R(A1, A2, A3)> : public cef_internal::CallbackBase {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3);
|
|
||||||
|
|
||||||
Callback() : CallbackBase(NULL) {}
|
|
||||||
|
|
||||||
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
|
||||||
// return the exact Callback<> type. See base/bind.h for details.
|
|
||||||
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
|
||||||
Callback(
|
|
||||||
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
|
|
||||||
: CallbackBase(bind_state) {
|
|
||||||
// Force the assignment to a local variable of PolymorphicInvoke
|
|
||||||
// so the compiler will typecheck that the passed in Run() method has
|
|
||||||
// the correct type.
|
|
||||||
PolymorphicInvoke invoke_func =
|
|
||||||
&cef_internal::BindState<Runnable, BindRunType,
|
|
||||||
BoundArgsType>::InvokerType::Run;
|
|
||||||
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Equals(const Callback& other) const {
|
|
||||||
return CallbackBase::Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3) const {
|
|
||||||
PolymorphicInvoke f =
|
|
||||||
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
|
||||||
|
|
||||||
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
|
|
||||||
cef_internal::CallbackForward(a2),
|
|
||||||
cef_internal::CallbackForward(a3));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef R (*PolymorphicInvoke)(
|
|
||||||
cef_internal::BindStateBase*,
|
|
||||||
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4>
|
|
||||||
class Callback<R(A1, A2, A3, A4)> : public cef_internal::CallbackBase {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4);
|
|
||||||
|
|
||||||
Callback() : CallbackBase(NULL) {}
|
|
||||||
|
|
||||||
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
|
||||||
// return the exact Callback<> type. See base/bind.h for details.
|
|
||||||
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
|
||||||
Callback(
|
|
||||||
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
|
|
||||||
: CallbackBase(bind_state) {
|
|
||||||
// Force the assignment to a local variable of PolymorphicInvoke
|
|
||||||
// so the compiler will typecheck that the passed in Run() method has
|
|
||||||
// the correct type.
|
|
||||||
PolymorphicInvoke invoke_func =
|
|
||||||
&cef_internal::BindState<Runnable, BindRunType,
|
|
||||||
BoundArgsType>::InvokerType::Run;
|
|
||||||
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Equals(const Callback& other) const {
|
|
||||||
return CallbackBase::Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4) const {
|
|
||||||
PolymorphicInvoke f =
|
|
||||||
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
|
||||||
|
|
||||||
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
|
|
||||||
cef_internal::CallbackForward(a2),
|
|
||||||
cef_internal::CallbackForward(a3),
|
|
||||||
cef_internal::CallbackForward(a4));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef R (*PolymorphicInvoke)(
|
|
||||||
cef_internal::BindStateBase*,
|
|
||||||
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R,
|
|
||||||
typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5>
|
|
||||||
class Callback<R(A1, A2, A3, A4, A5)> : public cef_internal::CallbackBase {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4, A5);
|
|
||||||
|
|
||||||
Callback() : CallbackBase(NULL) {}
|
|
||||||
|
|
||||||
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
|
||||||
// return the exact Callback<> type. See base/bind.h for details.
|
|
||||||
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
|
||||||
Callback(
|
|
||||||
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
|
|
||||||
: CallbackBase(bind_state) {
|
|
||||||
// Force the assignment to a local variable of PolymorphicInvoke
|
|
||||||
// so the compiler will typecheck that the passed in Run() method has
|
|
||||||
// the correct type.
|
|
||||||
PolymorphicInvoke invoke_func =
|
|
||||||
&cef_internal::BindState<Runnable, BindRunType,
|
|
||||||
BoundArgsType>::InvokerType::Run;
|
|
||||||
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Equals(const Callback& other) const {
|
|
||||||
return CallbackBase::Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5) const {
|
|
||||||
PolymorphicInvoke f =
|
|
||||||
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
|
||||||
|
|
||||||
return f(
|
|
||||||
bind_state_.get(), cef_internal::CallbackForward(a1),
|
|
||||||
cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3),
|
|
||||||
cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef R (*PolymorphicInvoke)(
|
|
||||||
cef_internal::BindStateBase*,
|
|
||||||
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A5>::ForwardType);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R,
|
|
||||||
typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5,
|
|
||||||
typename A6>
|
|
||||||
class Callback<R(A1, A2, A3, A4, A5, A6)> : public cef_internal::CallbackBase {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4, A5, A6);
|
|
||||||
|
|
||||||
Callback() : CallbackBase(NULL) {}
|
|
||||||
|
|
||||||
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
|
||||||
// return the exact Callback<> type. See base/bind.h for details.
|
|
||||||
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
|
||||||
Callback(
|
|
||||||
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
|
|
||||||
: CallbackBase(bind_state) {
|
|
||||||
// Force the assignment to a local variable of PolymorphicInvoke
|
|
||||||
// so the compiler will typecheck that the passed in Run() method has
|
|
||||||
// the correct type.
|
|
||||||
PolymorphicInvoke invoke_func =
|
|
||||||
&cef_internal::BindState<Runnable, BindRunType,
|
|
||||||
BoundArgsType>::InvokerType::Run;
|
|
||||||
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Equals(const Callback& other) const {
|
|
||||||
return CallbackBase::Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5,
|
|
||||||
typename cef_internal::CallbackParamTraits<A6>::ForwardType a6) const {
|
|
||||||
PolymorphicInvoke f =
|
|
||||||
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
|
||||||
|
|
||||||
return f(
|
|
||||||
bind_state_.get(), cef_internal::CallbackForward(a1),
|
|
||||||
cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3),
|
|
||||||
cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5),
|
|
||||||
cef_internal::CallbackForward(a6));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef R (*PolymorphicInvoke)(
|
|
||||||
cef_internal::BindStateBase*,
|
|
||||||
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A5>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A6>::ForwardType);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename R,
|
|
||||||
typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5,
|
|
||||||
typename A6,
|
|
||||||
typename A7>
|
|
||||||
class Callback<R(A1, A2, A3, A4, A5, A6, A7)>
|
|
||||||
: public cef_internal::CallbackBase {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
|
|
||||||
|
|
||||||
Callback() : CallbackBase(NULL) {}
|
|
||||||
|
|
||||||
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
|
|
||||||
// return the exact Callback<> type. See base/bind.h for details.
|
|
||||||
template <typename Runnable, typename BindRunType, typename BoundArgsType>
|
|
||||||
Callback(
|
|
||||||
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
|
|
||||||
: CallbackBase(bind_state) {
|
|
||||||
// Force the assignment to a local variable of PolymorphicInvoke
|
|
||||||
// so the compiler will typecheck that the passed in Run() method has
|
|
||||||
// the correct type.
|
|
||||||
PolymorphicInvoke invoke_func =
|
|
||||||
&cef_internal::BindState<Runnable, BindRunType,
|
|
||||||
BoundArgsType>::InvokerType::Run;
|
|
||||||
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Equals(const Callback& other) const {
|
|
||||||
return CallbackBase::Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
R Run(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5,
|
|
||||||
typename cef_internal::CallbackParamTraits<A6>::ForwardType a6,
|
|
||||||
typename cef_internal::CallbackParamTraits<A7>::ForwardType a7) const {
|
|
||||||
PolymorphicInvoke f =
|
|
||||||
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
|
|
||||||
|
|
||||||
return f(
|
|
||||||
bind_state_.get(), cef_internal::CallbackForward(a1),
|
|
||||||
cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3),
|
|
||||||
cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5),
|
|
||||||
cef_internal::CallbackForward(a6), cef_internal::CallbackForward(a7));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
typedef R (*PolymorphicInvoke)(
|
|
||||||
cef_internal::BindStateBase*,
|
|
||||||
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A5>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A6>::ForwardType,
|
|
||||||
typename cef_internal::CallbackParamTraits<A7>::ForwardType);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Syntactic sugar to make Callbacks<void(void)> easier to declare since it
|
|
||||||
// will be used in a lot of APIs with delayed execution.
|
|
||||||
typedef Callback<void(void)> Closure;
|
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|||||||
@@ -32,14 +32,9 @@
|
|||||||
#define INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_
|
#define INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_CALLBACK_FORWARD_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/callback_forward.h"
|
#include "base/functional/callback_forward.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
@@ -47,10 +42,19 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template <typename Sig>
|
template <typename Signature>
|
||||||
class Callback;
|
class OnceCallback;
|
||||||
|
|
||||||
typedef Callback<void(void)> Closure;
|
template <typename Signature>
|
||||||
|
class RepeatingCallback;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Syntactic sugar to make OnceClosure<void()> and RepeatingClosure<void()>
|
||||||
|
/// easier to declare since they will be used in a lot of APIs with delayed
|
||||||
|
/// execution.
|
||||||
|
///
|
||||||
|
using OnceClosure = OnceCallback<void()>;
|
||||||
|
using RepeatingClosure = RepeatingCallback<void()>;
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
@@ -32,60 +32,228 @@
|
|||||||
// are implemented using templates, with a class per callback signature, adding
|
// are implemented using templates, with a class per callback signature, adding
|
||||||
// methods to Callback<> itself is unattractive (lots of extra code gets
|
// methods to Callback<> itself is unattractive (lots of extra code gets
|
||||||
// generated). Instead, consider adding methods here.
|
// generated). Instead, consider adding methods here.
|
||||||
//
|
|
||||||
// ResetAndReturn(&cb) is like cb.Reset() but allows executing a callback (via a
|
|
||||||
// copy) after the original callback is Reset(). This can be handy if Run()
|
|
||||||
// reads/writes the variable holding the Callback.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
#define CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_CALLBACK_HELPERS_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/callback_helpers.h"
|
#include "base/functional/callback_helpers.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include "include/base/cef_basictypes.h"
|
#include <atomic>
|
||||||
#include "include/base/cef_build.h"
|
#include <memory>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "include/base/cef_bind.h"
|
||||||
#include "include/base/cef_callback.h"
|
#include "include/base/cef_callback.h"
|
||||||
#include "include/base/cef_macros.h"
|
#include "include/base/cef_logging.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template <typename Sig>
|
namespace internal {
|
||||||
base::Callback<Sig> ResetAndReturn(base::Callback<Sig>* cb) {
|
|
||||||
base::Callback<Sig> ret(*cb);
|
template <typename T>
|
||||||
cb->Reset();
|
struct IsBaseCallbackImpl : std::false_type {};
|
||||||
return ret;
|
|
||||||
|
template <typename R, typename... Args>
|
||||||
|
struct IsBaseCallbackImpl<OnceCallback<R(Args...)>> : std::true_type {};
|
||||||
|
|
||||||
|
template <typename R, typename... Args>
|
||||||
|
struct IsBaseCallbackImpl<RepeatingCallback<R(Args...)>> : std::true_type {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct IsOnceCallbackImpl : std::false_type {};
|
||||||
|
|
||||||
|
template <typename R, typename... Args>
|
||||||
|
struct IsOnceCallbackImpl<OnceCallback<R(Args...)>> : std::true_type {};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
///
|
||||||
|
/// IsBaseCallback<T>::value is true when T is any of the Closure or Callback
|
||||||
|
/// family of types.
|
||||||
|
///
|
||||||
|
template <typename T>
|
||||||
|
using IsBaseCallback = internal::IsBaseCallbackImpl<std::decay_t<T>>;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// IsOnceCallback<T>::value is true when T is a OnceClosure or OnceCallback
|
||||||
|
/// type.
|
||||||
|
///
|
||||||
|
template <typename T>
|
||||||
|
using IsOnceCallback = internal::IsOnceCallbackImpl<std::decay_t<T>>;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// SFINAE friendly enabler allowing to overload methods for both Repeating and
|
||||||
|
/// OnceCallbacks.
|
||||||
|
///
|
||||||
|
/// Usage:
|
||||||
|
/// <pre>
|
||||||
|
/// template <template <typename> class CallbackType,
|
||||||
|
/// ... other template args ...,
|
||||||
|
/// typename = EnableIfIsBaseCallback<CallbackType>>
|
||||||
|
/// void DoStuff(CallbackType<...> cb, ...);
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
template <template <typename> class CallbackType>
|
||||||
|
using EnableIfIsBaseCallback =
|
||||||
|
std::enable_if_t<IsBaseCallback<CallbackType<void()>>::value>;
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
class OnceCallbackHolder final {
|
||||||
|
public:
|
||||||
|
OnceCallbackHolder(OnceCallback<void(Args...)> callback,
|
||||||
|
bool ignore_extra_runs)
|
||||||
|
: callback_(std::move(callback)), ignore_extra_runs_(ignore_extra_runs) {
|
||||||
|
DCHECK(callback_);
|
||||||
|
}
|
||||||
|
OnceCallbackHolder(const OnceCallbackHolder&) = delete;
|
||||||
|
OnceCallbackHolder& operator=(const OnceCallbackHolder&) = delete;
|
||||||
|
|
||||||
|
void Run(Args... args) {
|
||||||
|
if (has_run_.exchange(true)) {
|
||||||
|
CHECK(ignore_extra_runs_) << "Both OnceCallbacks returned by "
|
||||||
|
"base::SplitOnceCallback() were run. "
|
||||||
|
"At most one of the pair should be run.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DCHECK(callback_);
|
||||||
|
std::move(callback_).Run(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
volatile std::atomic_bool has_run_{false};
|
||||||
|
base::OnceCallback<void(Args...)> callback_;
|
||||||
|
const bool ignore_extra_runs_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Wraps the given OnceCallback into a RepeatingCallback that relays its
|
||||||
|
/// invocation to the original OnceCallback on the first invocation. The
|
||||||
|
/// following invocations are just ignored.
|
||||||
|
///
|
||||||
|
/// Note that this deliberately subverts the Once/Repeating paradigm of
|
||||||
|
/// Callbacks but helps ease the migration from old-style Callbacks. Avoid if
|
||||||
|
/// possible; use if necessary for migration.
|
||||||
|
///
|
||||||
|
// TODO(tzik): Remove it. https://crbug.com/730593
|
||||||
|
template <typename... Args>
|
||||||
|
RepeatingCallback<void(Args...)> AdaptCallbackForRepeating(
|
||||||
|
OnceCallback<void(Args...)> callback) {
|
||||||
|
using Helper = internal::OnceCallbackHolder<Args...>;
|
||||||
|
return base::BindRepeating(
|
||||||
|
&Helper::Run, std::make_unique<Helper>(std::move(callback),
|
||||||
|
/*ignore_extra_runs=*/true));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScopedClosureRunner is akin to scoped_ptr for Closures. It ensures that the
|
///
|
||||||
// Closure is executed and deleted no matter how the current scope exits.
|
/// Wraps the given OnceCallback and returns two OnceCallbacks with an identical
|
||||||
|
/// signature. On first invokation of either returned callbacks, the original
|
||||||
|
/// callback is invoked. Invoking the remaining callback results in a crash.
|
||||||
|
///
|
||||||
|
template <typename... Args>
|
||||||
|
std::pair<OnceCallback<void(Args...)>, OnceCallback<void(Args...)>>
|
||||||
|
SplitOnceCallback(OnceCallback<void(Args...)> callback) {
|
||||||
|
using Helper = internal::OnceCallbackHolder<Args...>;
|
||||||
|
auto wrapped_once = base::BindRepeating(
|
||||||
|
&Helper::Run, std::make_unique<Helper>(std::move(callback),
|
||||||
|
/*ignore_extra_runs=*/false));
|
||||||
|
return std::make_pair(wrapped_once, wrapped_once);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// ScopedClosureRunner is akin to std::unique_ptr<> for Closures. It ensures
|
||||||
|
/// that the Closure is executed no matter how the current scope exits.
|
||||||
|
/// If you are looking for "ScopedCallback", "CallbackRunner", or
|
||||||
|
/// "CallbackScoper" this is the class you want.
|
||||||
|
///
|
||||||
class ScopedClosureRunner {
|
class ScopedClosureRunner {
|
||||||
public:
|
public:
|
||||||
ScopedClosureRunner();
|
ScopedClosureRunner();
|
||||||
explicit ScopedClosureRunner(const Closure& closure);
|
explicit ScopedClosureRunner(OnceClosure closure);
|
||||||
|
ScopedClosureRunner(ScopedClosureRunner&& other);
|
||||||
|
// Runs the current closure if it's set, then replaces it with the closure
|
||||||
|
// from |other|. This is akin to how unique_ptr frees the contained pointer in
|
||||||
|
// its move assignment operator. If you need to explicitly avoid running any
|
||||||
|
// current closure, use ReplaceClosure().
|
||||||
|
ScopedClosureRunner& operator=(ScopedClosureRunner&& other);
|
||||||
~ScopedClosureRunner();
|
~ScopedClosureRunner();
|
||||||
|
|
||||||
void Reset();
|
explicit operator bool() const { return !!closure_; }
|
||||||
void Reset(const Closure& closure);
|
|
||||||
Closure Release() WARN_UNUSED_RESULT;
|
// Calls the current closure and resets it, so it wont be called again.
|
||||||
|
void RunAndReset();
|
||||||
|
|
||||||
|
// Replaces closure with the new one releasing the old one without calling it.
|
||||||
|
void ReplaceClosure(OnceClosure closure);
|
||||||
|
|
||||||
|
// Releases the Closure without calling.
|
||||||
|
[[nodiscard]] OnceClosure Release();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Closure closure_;
|
OnceClosure closure_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ScopedClosureRunner);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Creates a null callback.
|
||||||
|
///
|
||||||
|
class NullCallback {
|
||||||
|
public:
|
||||||
|
template <typename R, typename... Args>
|
||||||
|
operator RepeatingCallback<R(Args...)>() const {
|
||||||
|
return RepeatingCallback<R(Args...)>();
|
||||||
|
}
|
||||||
|
template <typename R, typename... Args>
|
||||||
|
operator OnceCallback<R(Args...)>() const {
|
||||||
|
return OnceCallback<R(Args...)>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Creates a callback that does nothing when called.
|
||||||
|
///
|
||||||
|
class DoNothing {
|
||||||
|
public:
|
||||||
|
template <typename... Args>
|
||||||
|
operator RepeatingCallback<void(Args...)>() const {
|
||||||
|
return Repeatedly<Args...>();
|
||||||
|
}
|
||||||
|
template <typename... Args>
|
||||||
|
operator OnceCallback<void(Args...)>() const {
|
||||||
|
return Once<Args...>();
|
||||||
|
}
|
||||||
|
// Explicit way of specifying a specific callback type when the compiler can't
|
||||||
|
// deduce it.
|
||||||
|
template <typename... Args>
|
||||||
|
static RepeatingCallback<void(Args...)> Repeatedly() {
|
||||||
|
return BindRepeating([](Args... args) {});
|
||||||
|
}
|
||||||
|
template <typename... Args>
|
||||||
|
static OnceCallback<void(Args...)> Once() {
|
||||||
|
return BindOnce([](Args... args) {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Useful for creating a Closure that will delete a pointer when invoked. Only
|
||||||
|
/// use this when necessary. In most cases MessageLoop::DeleteSoon() is a better
|
||||||
|
/// fit.
|
||||||
|
///
|
||||||
|
template <typename T>
|
||||||
|
void DeletePointer(T* obj) {
|
||||||
|
delete obj;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|||||||
@@ -28,419 +28,373 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
///
|
||||||
|
/// \file
|
||||||
|
/// A container for a list of callbacks. Provides callers the ability to
|
||||||
|
/// manually or automatically unregister callbacks at any time, including during
|
||||||
|
/// callback notification.
|
||||||
|
///
|
||||||
|
/// TYPICAL USAGE:
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// class MyWidget {
|
||||||
|
/// public:
|
||||||
|
/// using CallbackList = base::RepeatingCallbackList<void(const Foo&)>;
|
||||||
|
///
|
||||||
|
/// // Registers |cb| to be called whenever NotifyFoo() is executed.
|
||||||
|
/// CallbackListSubscription RegisterCallback(CallbackList::CallbackType cb) {
|
||||||
|
/// return callback_list_.Add(std::move(cb));
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// private:
|
||||||
|
/// // Calls all registered callbacks, with |foo| as the supplied arg.
|
||||||
|
/// void NotifyFoo(const Foo& foo) {
|
||||||
|
/// callback_list_.Notify(foo);
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// CallbackList callback_list_;
|
||||||
|
/// };
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// class MyWidgetListener {
|
||||||
|
/// private:
|
||||||
|
/// void OnFoo(const Foo& foo) {
|
||||||
|
/// // Called whenever MyWidget::NotifyFoo() is executed, unless
|
||||||
|
/// // |foo_subscription_| has been destroyed.
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// // Automatically deregisters the callback when deleted (e.g. in
|
||||||
|
/// // ~MyWidgetListener()). Unretained(this) is safe here since the
|
||||||
|
/// // ScopedClosureRunner does not outlive |this|.
|
||||||
|
/// CallbackListSubscription foo_subscription_ =
|
||||||
|
/// MyWidget::Get()->RegisterCallback(
|
||||||
|
/// base::BindRepeating(&MyWidgetListener::OnFoo,
|
||||||
|
/// base::Unretained(this)));
|
||||||
|
/// };
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// UNSUPPORTED:
|
||||||
|
///
|
||||||
|
/// * Destroying the CallbackList during callback notification.
|
||||||
|
///
|
||||||
|
/// This is possible to support, but not currently necessary.
|
||||||
|
///
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
#define CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_CALLBACK_LIST_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/callback_list.h"
|
#include "base/functional/callback_list.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "include/base/cef_basictypes.h"
|
#include "include/base/cef_auto_reset.h"
|
||||||
#include "include/base/cef_build.h"
|
#include "include/base/cef_bind.h"
|
||||||
#include "include/base/cef_callback.h"
|
#include "include/base/cef_callback.h"
|
||||||
|
#include "include/base/cef_callback_helpers.h"
|
||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/cef_macros.h"
|
#include "include/base/cef_weak_ptr.h"
|
||||||
#include "include/base/cef_scoped_ptr.h"
|
|
||||||
#include "include/base/internal/cef_callback_internal.h"
|
|
||||||
|
|
||||||
// OVERVIEW:
|
|
||||||
//
|
|
||||||
// A container for a list of callbacks. Unlike a normal STL vector or list,
|
|
||||||
// this container can be modified during iteration without invalidating the
|
|
||||||
// iterator. It safely handles the case of a callback removing itself
|
|
||||||
// or another callback from the list while callbacks are being run.
|
|
||||||
//
|
|
||||||
// TYPICAL USAGE:
|
|
||||||
//
|
|
||||||
// class MyWidget {
|
|
||||||
// public:
|
|
||||||
// ...
|
|
||||||
//
|
|
||||||
// typedef base::Callback<void(const Foo&)> OnFooCallback;
|
|
||||||
//
|
|
||||||
// scoped_ptr<base::CallbackList<void(const Foo&)>::Subscription>
|
|
||||||
// RegisterCallback(const OnFooCallback& cb) {
|
|
||||||
// return callback_list_.Add(cb);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private:
|
|
||||||
// void NotifyFoo(const Foo& foo) {
|
|
||||||
// callback_list_.Notify(foo);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// base::CallbackList<void(const Foo&)> callback_list_;
|
|
||||||
//
|
|
||||||
// DISALLOW_COPY_AND_ASSIGN(MyWidget);
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// class MyWidgetListener {
|
|
||||||
// public:
|
|
||||||
// MyWidgetListener::MyWidgetListener() {
|
|
||||||
// foo_subscription_ = MyWidget::GetCurrent()->RegisterCallback(
|
|
||||||
// base::Bind(&MyWidgetListener::OnFoo, this)));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// MyWidgetListener::~MyWidgetListener() {
|
|
||||||
// // Subscription gets deleted automatically and will deregister
|
|
||||||
// // the callback in the process.
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private:
|
|
||||||
// void OnFoo(const Foo& foo) {
|
|
||||||
// // Do something.
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// scoped_ptr<base::CallbackList<void(const Foo&)>::Subscription>
|
|
||||||
// foo_subscription_;
|
|
||||||
//
|
|
||||||
// DISALLOW_COPY_AND_ASSIGN(MyWidgetListener);
|
|
||||||
// };
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
namespace internal {
|
||||||
|
template <typename CallbackListImpl>
|
||||||
|
class CallbackListBase;
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
namespace cef_internal {
|
template <typename Signature>
|
||||||
|
class OnceCallbackList;
|
||||||
|
|
||||||
template <typename CallbackType>
|
template <typename Signature>
|
||||||
|
class RepeatingCallbackList;
|
||||||
|
|
||||||
|
// A trimmed-down version of ScopedClosureRunner that can be used to guarantee a
|
||||||
|
// closure is run on destruction. This is designed to be used by
|
||||||
|
// CallbackListBase to run CancelCallback() when this subscription dies;
|
||||||
|
// consumers can avoid callbacks on dead objects by ensuring the subscription
|
||||||
|
// returned by CallbackListBase::Add() does not outlive the bound object in the
|
||||||
|
// callback. A typical way to do this is to bind a callback to a member function
|
||||||
|
// on `this` and store the returned subscription as a member variable.
|
||||||
|
class CallbackListSubscription {
|
||||||
|
public:
|
||||||
|
CallbackListSubscription();
|
||||||
|
CallbackListSubscription(CallbackListSubscription&& subscription);
|
||||||
|
CallbackListSubscription& operator=(CallbackListSubscription&& subscription);
|
||||||
|
~CallbackListSubscription();
|
||||||
|
|
||||||
|
explicit operator bool() const { return !!closure_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename T>
|
||||||
|
friend class internal::CallbackListBase;
|
||||||
|
|
||||||
|
explicit CallbackListSubscription(base::OnceClosure closure);
|
||||||
|
|
||||||
|
void Run();
|
||||||
|
|
||||||
|
OnceClosure closure_;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
// From base/stl_util.h.
|
||||||
|
template <class T, class Allocator, class Predicate>
|
||||||
|
size_t EraseIf(std::list<T, Allocator>& container, Predicate pred) {
|
||||||
|
size_t old_size = container.size();
|
||||||
|
container.remove_if(pred);
|
||||||
|
return old_size - container.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// A traits class to break circular type dependencies between CallbackListBase
|
||||||
|
// and its subclasses.
|
||||||
|
template <typename CallbackList>
|
||||||
|
struct CallbackListTraits;
|
||||||
|
|
||||||
|
// NOTE: It's important that Callbacks provide iterator stability when items are
|
||||||
|
// added to the end, so e.g. a std::vector<> is not suitable here.
|
||||||
|
template <typename Signature>
|
||||||
|
struct CallbackListTraits<OnceCallbackList<Signature>> {
|
||||||
|
using CallbackType = OnceCallback<Signature>;
|
||||||
|
using Callbacks = std::list<CallbackType>;
|
||||||
|
};
|
||||||
|
template <typename Signature>
|
||||||
|
struct CallbackListTraits<RepeatingCallbackList<Signature>> {
|
||||||
|
using CallbackType = RepeatingCallback<Signature>;
|
||||||
|
using Callbacks = std::list<CallbackType>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename CallbackListImpl>
|
||||||
class CallbackListBase {
|
class CallbackListBase {
|
||||||
public:
|
public:
|
||||||
class Subscription {
|
using CallbackType =
|
||||||
public:
|
typename CallbackListTraits<CallbackListImpl>::CallbackType;
|
||||||
Subscription(CallbackListBase<CallbackType>* list,
|
static_assert(IsBaseCallback<CallbackType>::value, "");
|
||||||
typename std::list<CallbackType>::iterator iter)
|
|
||||||
: list_(list), iter_(iter) {}
|
|
||||||
|
|
||||||
~Subscription() {
|
// TODO(crbug.com/1103086): Update references to use this directly and by
|
||||||
if (list_->active_iterator_count_) {
|
// value, then remove.
|
||||||
iter_->Reset();
|
using Subscription = CallbackListSubscription;
|
||||||
} else {
|
|
||||||
list_->callbacks_.erase(iter_);
|
CallbackListBase() = default;
|
||||||
if (!list_->removal_callback_.is_null())
|
CallbackListBase(const CallbackListBase&) = delete;
|
||||||
list_->removal_callback_.Run();
|
CallbackListBase& operator=(const CallbackListBase&) = delete;
|
||||||
|
|
||||||
|
~CallbackListBase() {
|
||||||
|
// Destroying the list during iteration is unsupported and will cause a UAF.
|
||||||
|
CHECK(!iterating_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registers |cb| for future notifications. Returns a CallbackListSubscription
|
||||||
|
// whose destruction will cancel |cb|.
|
||||||
|
[[nodiscard]] CallbackListSubscription Add(CallbackType cb) {
|
||||||
|
DCHECK(!cb.is_null());
|
||||||
|
return CallbackListSubscription(base::BindOnce(
|
||||||
|
&CallbackListBase::CancelCallback, weak_ptr_factory_.GetWeakPtr(),
|
||||||
|
callbacks_.insert(callbacks_.end(), std::move(cb))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registers |cb| for future notifications. Provides no way for the caller to
|
||||||
|
// cancel, so this is only safe for cases where the callback is guaranteed to
|
||||||
|
// live at least as long as this list (e.g. if it's bound on the same object
|
||||||
|
// that owns the list).
|
||||||
|
// TODO(pkasting): Attempt to use Add() instead and see if callers can relax
|
||||||
|
// other lifetime/ordering mechanisms as a result.
|
||||||
|
void AddUnsafe(CallbackType cb) {
|
||||||
|
DCHECK(!cb.is_null());
|
||||||
|
callbacks_.push_back(std::move(cb));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registers |removal_callback| to be run after elements are removed from the
|
||||||
|
// list of registered callbacks.
|
||||||
|
void set_removal_callback(const RepeatingClosure& removal_callback) {
|
||||||
|
removal_callback_ = removal_callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns whether the list of registered callbacks is empty (from an external
|
||||||
|
// perspective -- meaning no remaining callbacks are live).
|
||||||
|
bool empty() const {
|
||||||
|
return std::all_of(callbacks_.cbegin(), callbacks_.cend(),
|
||||||
|
[](const auto& callback) { return callback.is_null(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calls all registered callbacks that are not canceled beforehand. If any
|
||||||
|
// callbacks are unregistered, notifies any registered removal callback at the
|
||||||
|
// end.
|
||||||
|
//
|
||||||
|
// Arguments must be copyable, since they must be supplied to all callbacks.
|
||||||
|
// Move-only types would be destructively modified by passing them to the
|
||||||
|
// first callback and not reach subsequent callbacks as intended.
|
||||||
|
//
|
||||||
|
// Notify() may be called re-entrantly, in which case the nested call
|
||||||
|
// completes before the outer one continues. Callbacks are only ever added at
|
||||||
|
// the end and canceled callbacks are not pruned from the list until the
|
||||||
|
// outermost iteration completes, so existing iterators should never be
|
||||||
|
// invalidated. However, this does mean that a callback added during a nested
|
||||||
|
// call can be notified by outer calls -- meaning it will be notified about
|
||||||
|
// things that happened before it was added -- if its subscription outlives
|
||||||
|
// the reentrant Notify() call.
|
||||||
|
template <typename... RunArgs>
|
||||||
|
void Notify(RunArgs&&... args) {
|
||||||
|
if (empty()) {
|
||||||
|
return; // Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
AutoReset<bool> iterating(&iterating_, true);
|
||||||
|
|
||||||
|
// Skip any callbacks that are canceled during iteration.
|
||||||
|
// NOTE: Since RunCallback() may call Add(), it's not safe to cache the
|
||||||
|
// value of callbacks_.end() across loop iterations.
|
||||||
|
const auto next_valid = [this](const auto it) {
|
||||||
|
return std::find_if_not(it, callbacks_.end(), [](const auto& callback) {
|
||||||
|
return callback.is_null();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
for (auto it = next_valid(callbacks_.begin()); it != callbacks_.end();
|
||||||
|
it = next_valid(it)) {
|
||||||
|
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...,
|
||||||
|
// since that would allow move-only arguments.
|
||||||
|
static_cast<CallbackListImpl*>(this)->RunCallback(it++, args...);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
// Re-entrant invocations shouldn't prune anything from the list. This can
|
||||||
CallbackListBase<CallbackType>* list_;
|
// invalidate iterators from underneath higher call frames. It's safe to
|
||||||
typename std::list<CallbackType>::iterator iter_;
|
// simply do nothing, since the outermost frame will continue through here
|
||||||
|
// and prune all null callbacks below.
|
||||||
|
if (iterating_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Subscription);
|
// Any null callbacks remaining in the list were canceled due to
|
||||||
};
|
// Subscription destruction during iteration, and can safely be erased now.
|
||||||
|
const size_t erased_callbacks =
|
||||||
|
EraseIf(callbacks_, [](const auto& cb) { return cb.is_null(); });
|
||||||
|
|
||||||
// Add a callback to the list. The callback will remain registered until the
|
// Run |removal_callback_| if any callbacks were canceled. Note that we
|
||||||
// returned Subscription is destroyed, which must occur before the
|
// cannot simply compare list sizes before and after iterating, since
|
||||||
// CallbackList is destroyed.
|
// notification may result in Add()ing new callbacks as well as canceling
|
||||||
scoped_ptr<Subscription> Add(const CallbackType& cb) WARN_UNUSED_RESULT {
|
// them. Also note that if this is a OnceCallbackList, the OnceCallbacks
|
||||||
DCHECK(!cb.is_null());
|
// that were executed above have all been removed regardless of whether
|
||||||
return scoped_ptr<Subscription>(
|
// they're counted in |erased_callbacks_|.
|
||||||
new Subscription(this, callbacks_.insert(callbacks_.end(), cb)));
|
if (removal_callback_ &&
|
||||||
}
|
(erased_callbacks || IsOnceCallback<CallbackType>::value)) {
|
||||||
|
removal_callback_.Run(); // May delete |this|!
|
||||||
// Sets a callback which will be run when a subscription list is changed.
|
}
|
||||||
void set_removal_callback(const Closure& callback) {
|
|
||||||
removal_callback_ = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if there are no subscriptions. This is only valid to call when
|
|
||||||
// not looping through the list.
|
|
||||||
bool empty() {
|
|
||||||
DCHECK_EQ(0, active_iterator_count_);
|
|
||||||
return callbacks_.empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// An iterator class that can be used to access the list of callbacks.
|
using Callbacks = typename CallbackListTraits<CallbackListImpl>::Callbacks;
|
||||||
class Iterator {
|
|
||||||
public:
|
// Holds non-null callbacks, which will be called during Notify().
|
||||||
explicit Iterator(CallbackListBase<CallbackType>* list)
|
Callbacks callbacks_;
|
||||||
: list_(list), list_iter_(list_->callbacks_.begin()) {
|
|
||||||
++list_->active_iterator_count_;
|
private:
|
||||||
|
// Cancels the callback pointed to by |it|, which is guaranteed to be valid.
|
||||||
|
void CancelCallback(const typename Callbacks::iterator& it) {
|
||||||
|
if (static_cast<CallbackListImpl*>(this)->CancelNullCallback(it)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator(const Iterator& iter)
|
if (iterating_) {
|
||||||
: list_(iter.list_), list_iter_(iter.list_iter_) {
|
// Calling erase() here is unsafe, since the loop in Notify() may be
|
||||||
++list_->active_iterator_count_;
|
// referencing this same iterator, e.g. if adjacent callbacks'
|
||||||
}
|
// Subscriptions are both destroyed when the first one is Run(). Just
|
||||||
|
// reset the callback and let Notify() clean it up at the end.
|
||||||
~Iterator() {
|
it->Reset();
|
||||||
if (list_ && --list_->active_iterator_count_ == 0) {
|
} else {
|
||||||
list_->Compact();
|
callbacks_.erase(it);
|
||||||
|
if (removal_callback_) {
|
||||||
|
removal_callback_.Run(); // May delete |this|!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CallbackType* GetNext() {
|
|
||||||
while ((list_iter_ != list_->callbacks_.end()) && list_iter_->is_null())
|
|
||||||
++list_iter_;
|
|
||||||
|
|
||||||
CallbackType* cb = NULL;
|
|
||||||
if (list_iter_ != list_->callbacks_.end()) {
|
|
||||||
cb = &(*list_iter_);
|
|
||||||
++list_iter_;
|
|
||||||
}
|
|
||||||
return cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
CallbackListBase<CallbackType>* list_;
|
|
||||||
typename std::list<CallbackType>::iterator list_iter_;
|
|
||||||
};
|
|
||||||
|
|
||||||
CallbackListBase() : active_iterator_count_(0) {}
|
|
||||||
|
|
||||||
~CallbackListBase() {
|
|
||||||
DCHECK_EQ(0, active_iterator_count_);
|
|
||||||
DCHECK_EQ(0U, callbacks_.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an instance of a CallbackListBase::Iterator which can be used
|
// Set while Notify() is traversing |callbacks_|. Used primarily to avoid
|
||||||
// to run callbacks.
|
// invalidating iterators that may be in use.
|
||||||
Iterator GetIterator() { return Iterator(this); }
|
bool iterating_ = false;
|
||||||
|
|
||||||
// Compact the list: remove any entries which were NULLed out during
|
// Called after elements are removed from |callbacks_|.
|
||||||
// iteration.
|
RepeatingClosure removal_callback_;
|
||||||
void Compact() {
|
|
||||||
typename std::list<CallbackType>::iterator it = callbacks_.begin();
|
|
||||||
bool updated = false;
|
|
||||||
while (it != callbacks_.end()) {
|
|
||||||
if ((*it).is_null()) {
|
|
||||||
updated = true;
|
|
||||||
it = callbacks_.erase(it);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updated && !removal_callback_.is_null())
|
WeakPtrFactory<CallbackListBase> weak_ptr_factory_{this};
|
||||||
removal_callback_.Run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::list<CallbackType> callbacks_;
|
|
||||||
int active_iterator_count_;
|
|
||||||
Closure removal_callback_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CallbackListBase);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cef_internal
|
} // namespace internal
|
||||||
|
|
||||||
template <typename Sig>
|
template <typename Signature>
|
||||||
class CallbackList;
|
class OnceCallbackList
|
||||||
|
: public internal::CallbackListBase<OnceCallbackList<Signature>> {
|
||||||
|
private:
|
||||||
|
friend internal::CallbackListBase<OnceCallbackList>;
|
||||||
|
using Traits = internal::CallbackListTraits<OnceCallbackList>;
|
||||||
|
|
||||||
template <>
|
// Runs the current callback, which may cancel it or any other callbacks.
|
||||||
class CallbackList<void(void)>
|
template <typename... RunArgs>
|
||||||
: public cef_internal::CallbackListBase<Callback<void(void)>> {
|
void RunCallback(typename Traits::Callbacks::iterator it, RunArgs&&... args) {
|
||||||
public:
|
// OnceCallbacks still have Subscriptions with outstanding iterators;
|
||||||
typedef Callback<void(void)> CallbackType;
|
// splice() removes them from |callbacks_| without invalidating those.
|
||||||
|
null_callbacks_.splice(null_callbacks_.end(), this->callbacks_, it);
|
||||||
|
|
||||||
CallbackList() {}
|
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...; see
|
||||||
|
// comments in Notify().
|
||||||
void Notify() {
|
std::move(*it).Run(args...);
|
||||||
cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
|
||||||
this->GetIterator();
|
|
||||||
CallbackType* cb;
|
|
||||||
while ((cb = it.GetNext()) != NULL) {
|
|
||||||
cb->Run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
// If |it| refers to an already-canceled callback, does any necessary cleanup
|
||||||
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
// and returns true. Otherwise returns false.
|
||||||
};
|
bool CancelNullCallback(const typename Traits::Callbacks::iterator& it) {
|
||||||
|
if (it->is_null()) {
|
||||||
template <typename A1>
|
null_callbacks_.erase(it);
|
||||||
class CallbackList<void(A1)>
|
return true;
|
||||||
: public cef_internal::CallbackListBase<Callback<void(A1)>> {
|
|
||||||
public:
|
|
||||||
typedef Callback<void(A1)> CallbackType;
|
|
||||||
|
|
||||||
CallbackList() {}
|
|
||||||
|
|
||||||
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1) {
|
|
||||||
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
|
||||||
this->GetIterator();
|
|
||||||
CallbackType* cb;
|
|
||||||
while ((cb = it.GetNext()) != NULL) {
|
|
||||||
cb->Run(a1);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
// Holds null callbacks whose Subscriptions are still alive, so the
|
||||||
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
// Subscriptions will still contain valid iterators. Only needed for
|
||||||
|
// OnceCallbacks, since RepeatingCallbacks are not canceled except by
|
||||||
|
// Subscription destruction.
|
||||||
|
typename Traits::Callbacks null_callbacks_;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename A1, typename A2>
|
template <typename Signature>
|
||||||
class CallbackList<void(A1, A2)>
|
class RepeatingCallbackList
|
||||||
: public cef_internal::CallbackListBase<Callback<void(A1, A2)>> {
|
: public internal::CallbackListBase<RepeatingCallbackList<Signature>> {
|
||||||
public:
|
private:
|
||||||
typedef Callback<void(A1, A2)> CallbackType;
|
friend internal::CallbackListBase<RepeatingCallbackList>;
|
||||||
|
using Traits = internal::CallbackListTraits<RepeatingCallbackList>;
|
||||||
CallbackList() {}
|
// Runs the current callback, which may cancel it or any other callbacks.
|
||||||
|
template <typename... RunArgs>
|
||||||
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
void RunCallback(typename Traits::Callbacks::iterator it, RunArgs&&... args) {
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2) {
|
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...; see
|
||||||
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
// comments in Notify().
|
||||||
this->GetIterator();
|
it->Run(args...);
|
||||||
CallbackType* cb;
|
|
||||||
while ((cb = it.GetNext()) != NULL) {
|
|
||||||
cb->Run(a1, a2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
// If |it| refers to an already-canceled callback, does any necessary cleanup
|
||||||
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
// and returns true. Otherwise returns false.
|
||||||
};
|
bool CancelNullCallback(const typename Traits::Callbacks::iterator& it) {
|
||||||
|
// Because at most one Subscription can point to a given callback, and
|
||||||
template <typename A1, typename A2, typename A3>
|
// RepeatingCallbacks are only reset by CancelCallback(), no one should be
|
||||||
class CallbackList<void(A1, A2, A3)>
|
// able to request cancellation of a canceled RepeatingCallback.
|
||||||
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3)>> {
|
DCHECK(!it->is_null());
|
||||||
public:
|
return false;
|
||||||
typedef Callback<void(A1, A2, A3)> CallbackType;
|
|
||||||
|
|
||||||
CallbackList() {}
|
|
||||||
|
|
||||||
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3) {
|
|
||||||
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
|
||||||
this->GetIterator();
|
|
||||||
CallbackType* cb;
|
|
||||||
while ((cb = it.GetNext()) != NULL) {
|
|
||||||
cb->Run(a1, a2, a3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4>
|
///
|
||||||
class CallbackList<void(A1, A2, A3, A4)>
|
/// Syntactic sugar to parallel that used for Callbacks.
|
||||||
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4)>> {
|
///
|
||||||
public:
|
using OnceClosureList = OnceCallbackList<void()>;
|
||||||
typedef Callback<void(A1, A2, A3, A4)> CallbackType;
|
using RepeatingClosureList = RepeatingCallbackList<void()>;
|
||||||
|
|
||||||
CallbackList() {}
|
|
||||||
|
|
||||||
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4) {
|
|
||||||
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
|
||||||
this->GetIterator();
|
|
||||||
CallbackType* cb;
|
|
||||||
while ((cb = it.GetNext()) != NULL) {
|
|
||||||
cb->Run(a1, a2, a3, a4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2, typename A3, typename A4, typename A5>
|
|
||||||
class CallbackList<void(A1, A2, A3, A4, A5)>
|
|
||||||
: public cef_internal::CallbackListBase<
|
|
||||||
Callback<void(A1, A2, A3, A4, A5)>> {
|
|
||||||
public:
|
|
||||||
typedef Callback<void(A1, A2, A3, A4, A5)> CallbackType;
|
|
||||||
|
|
||||||
CallbackList() {}
|
|
||||||
|
|
||||||
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5) {
|
|
||||||
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
|
||||||
this->GetIterator();
|
|
||||||
CallbackType* cb;
|
|
||||||
while ((cb = it.GetNext()) != NULL) {
|
|
||||||
cb->Run(a1, a2, a3, a4, a5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5,
|
|
||||||
typename A6>
|
|
||||||
class CallbackList<void(A1, A2, A3, A4, A5, A6)>
|
|
||||||
: public cef_internal::CallbackListBase<
|
|
||||||
Callback<void(A1, A2, A3, A4, A5, A6)>> {
|
|
||||||
public:
|
|
||||||
typedef Callback<void(A1, A2, A3, A4, A5, A6)> CallbackType;
|
|
||||||
|
|
||||||
CallbackList() {}
|
|
||||||
|
|
||||||
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5,
|
|
||||||
typename cef_internal::CallbackParamTraits<A6>::ForwardType a6) {
|
|
||||||
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
|
||||||
this->GetIterator();
|
|
||||||
CallbackType* cb;
|
|
||||||
while ((cb = it.GetNext()) != NULL) {
|
|
||||||
cb->Run(a1, a2, a3, a4, a5, a6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5,
|
|
||||||
typename A6,
|
|
||||||
typename A7>
|
|
||||||
class CallbackList<void(A1, A2, A3, A4, A5, A6, A7)>
|
|
||||||
: public cef_internal::CallbackListBase<
|
|
||||||
Callback<void(A1, A2, A3, A4, A5, A6, A7)>> {
|
|
||||||
public:
|
|
||||||
typedef Callback<void(A1, A2, A3, A4, A5, A6, A7)> CallbackType;
|
|
||||||
|
|
||||||
CallbackList() {}
|
|
||||||
|
|
||||||
void Notify(typename cef_internal::CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename cef_internal::CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename cef_internal::CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename cef_internal::CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename cef_internal::CallbackParamTraits<A5>::ForwardType a5,
|
|
||||||
typename cef_internal::CallbackParamTraits<A6>::ForwardType a6,
|
|
||||||
typename cef_internal::CallbackParamTraits<A7>::ForwardType a7) {
|
|
||||||
typename cef_internal::CallbackListBase<CallbackType>::Iterator it =
|
|
||||||
this->GetIterator();
|
|
||||||
CallbackType* cb;
|
|
||||||
while ((cb = it.GetNext()) != NULL) {
|
|
||||||
cb->Run(a1, a2, a3, a4, a5, a6, a7);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CallbackList);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
@@ -27,54 +27,58 @@
|
|||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
|
||||||
// CancelableCallback is a wrapper around base::Callback that allows
|
///
|
||||||
// cancellation of a callback. CancelableCallback takes a reference on the
|
/// \file
|
||||||
// wrapped callback until this object is destroyed or Reset()/Cancel() are
|
/// CancelableCallback is a wrapper around base::Callback that allows
|
||||||
// called.
|
/// cancellation of a callback. CancelableCallback takes a reference on the
|
||||||
//
|
/// wrapped callback until this object is destroyed or Reset()/Cancel() are
|
||||||
// NOTE:
|
/// called.
|
||||||
//
|
///
|
||||||
// Calling CancelableCallback::Cancel() brings the object back to its natural,
|
/// NOTE:
|
||||||
// default-constructed state, i.e., CancelableCallback::callback() will return
|
///
|
||||||
// a null callback.
|
/// Calling CancelableCallback::Cancel() brings the object back to its natural,
|
||||||
//
|
/// default-constructed state, i.e., CancelableCallback::callback() will return
|
||||||
// THREAD-SAFETY:
|
/// a null callback.
|
||||||
//
|
///
|
||||||
// CancelableCallback objects must be created on, posted to, cancelled on, and
|
/// THREAD-SAFETY:
|
||||||
// destroyed on the same thread.
|
///
|
||||||
//
|
/// CancelableCallback objects must be created on, posted to, cancelled on, and
|
||||||
//
|
/// destroyed on the same thread.
|
||||||
// EXAMPLE USAGE:
|
///
|
||||||
//
|
///
|
||||||
// In the following example, the test is verifying that RunIntensiveTest()
|
/// EXAMPLE USAGE:
|
||||||
// Quit()s the message loop within 4 seconds. The cancelable callback is posted
|
///
|
||||||
// to the message loop, the intensive test runs, the message loop is run,
|
/// In the following example, the test is verifying that RunIntensiveTest()
|
||||||
// then the callback is cancelled.
|
/// Quit()s the message loop within 4 seconds. The cancelable callback is posted
|
||||||
//
|
/// to the message loop, the intensive test runs, the message loop is run,
|
||||||
// void TimeoutCallback(const std::string& timeout_message) {
|
/// then the callback is cancelled.
|
||||||
// FAIL() << timeout_message;
|
///
|
||||||
// MessageLoop::current()->QuitWhenIdle();
|
/// <pre>
|
||||||
// }
|
/// RunLoop run_loop;
|
||||||
//
|
///
|
||||||
// CancelableClosure timeout(base::Bind(&TimeoutCallback, "Test timed out."));
|
/// void TimeoutCallback(const std::string& timeout_message) {
|
||||||
// MessageLoop::current()->PostDelayedTask(FROM_HERE, timeout.callback(),
|
/// FAIL() << timeout_message;
|
||||||
// 4000) // 4 seconds to run.
|
/// run_loop.QuitWhenIdle();
|
||||||
// RunIntensiveTest();
|
/// }
|
||||||
// MessageLoop::current()->Run();
|
///
|
||||||
// timeout.Cancel(); // Hopefully this is hit before the timeout callback runs.
|
/// CancelableOnceClosure timeout(
|
||||||
//
|
/// base::BindOnce(&TimeoutCallback, "Test timed out."));
|
||||||
|
/// ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE,
|
||||||
|
/// timeout.callback(),
|
||||||
|
/// TimeDelta::FromSeconds(4));
|
||||||
|
/// RunIntensiveTest();
|
||||||
|
/// run_loop.Run();
|
||||||
|
/// // Hopefully this is hit before the timeout callback runs.
|
||||||
|
/// timeout.Cancel();
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
#define CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_CANCELABLE_CALLBACK_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/cancelable_callback.h"
|
#include "base/cancelable_callback.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -82,37 +86,36 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "include/base/cef_bind.h"
|
#include "include/base/cef_bind.h"
|
||||||
#include "include/base/cef_build.h"
|
|
||||||
#include "include/base/cef_callback.h"
|
#include "include/base/cef_callback.h"
|
||||||
|
#include "include/base/cef_compiler_specific.h"
|
||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/cef_macros.h"
|
|
||||||
#include "include/base/cef_weak_ptr.h"
|
#include "include/base/cef_weak_ptr.h"
|
||||||
#include "include/base/internal/cef_callback_internal.h"
|
#include "include/base/internal/cef_callback_internal.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
template <typename Sig>
|
template <typename CallbackType>
|
||||||
class CancelableCallback;
|
class CancelableCallbackImpl {
|
||||||
|
|
||||||
template <>
|
|
||||||
class CancelableCallback<void(void)> {
|
|
||||||
public:
|
public:
|
||||||
CancelableCallback() : weak_factory_(this) {}
|
CancelableCallbackImpl() = default;
|
||||||
|
CancelableCallbackImpl(const CancelableCallbackImpl&) = delete;
|
||||||
|
CancelableCallbackImpl& operator=(const CancelableCallbackImpl&) = delete;
|
||||||
|
|
||||||
// |callback| must not be null.
|
// |callback| must not be null.
|
||||||
explicit CancelableCallback(const base::Callback<void(void)>& callback)
|
explicit CancelableCallbackImpl(CallbackType callback)
|
||||||
: weak_factory_(this), callback_(callback) {
|
: callback_(std::move(callback)) {
|
||||||
DCHECK(!callback.is_null());
|
DCHECK(callback_);
|
||||||
InitializeForwarder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~CancelableCallback() {}
|
~CancelableCallbackImpl() = default;
|
||||||
|
|
||||||
// Cancels and drops the reference to the wrapped callback.
|
// Cancels and drops the reference to the wrapped callback.
|
||||||
void Cancel() {
|
void Cancel() {
|
||||||
weak_factory_.InvalidateWeakPtrs();
|
weak_ptr_factory_.InvalidateWeakPtrs();
|
||||||
forwarder_.Reset();
|
|
||||||
callback_.Reset();
|
callback_.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,170 +124,69 @@ class CancelableCallback<void(void)> {
|
|||||||
|
|
||||||
// Sets |callback| as the closure that may be cancelled. |callback| may not
|
// Sets |callback| as the closure that may be cancelled. |callback| may not
|
||||||
// be null. Outstanding and any previously wrapped callbacks are cancelled.
|
// be null. Outstanding and any previously wrapped callbacks are cancelled.
|
||||||
void Reset(const base::Callback<void(void)>& callback) {
|
void Reset(CallbackType callback) {
|
||||||
DCHECK(!callback.is_null());
|
DCHECK(callback);
|
||||||
|
|
||||||
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
||||||
Cancel();
|
Cancel();
|
||||||
|
callback_ = std::move(callback);
|
||||||
// |forwarder_| is no longer valid after Cancel(), so re-bind.
|
|
||||||
InitializeForwarder();
|
|
||||||
|
|
||||||
callback_ = callback;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a callback that can be disabled by calling Cancel().
|
// Returns a callback that can be disabled by calling Cancel().
|
||||||
const base::Callback<void(void)>& callback() const { return forwarder_; }
|
CallbackType callback() const {
|
||||||
|
if (!callback_) {
|
||||||
|
return CallbackType();
|
||||||
|
}
|
||||||
|
CallbackType forwarder;
|
||||||
|
MakeForwarder(&forwarder);
|
||||||
|
return forwarder;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Forward() { callback_.Run(); }
|
template <typename... Args>
|
||||||
|
void MakeForwarder(RepeatingCallback<void(Args...)>* out) const {
|
||||||
// Helper method to bind |forwarder_| using a weak pointer from
|
using ForwarderType = void (CancelableCallbackImpl::*)(Args...);
|
||||||
// |weak_factory_|.
|
ForwarderType forwarder = &CancelableCallbackImpl::ForwardRepeating;
|
||||||
void InitializeForwarder() {
|
*out = BindRepeating(forwarder, weak_ptr_factory_.GetWeakPtr());
|
||||||
forwarder_ = base::Bind(&CancelableCallback<void(void)>::Forward,
|
|
||||||
weak_factory_.GetWeakPtr());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to ensure Forward() is not run when this object is destroyed.
|
template <typename... Args>
|
||||||
base::WeakPtrFactory<CancelableCallback<void(void)>> weak_factory_;
|
void MakeForwarder(OnceCallback<void(Args...)>* out) const {
|
||||||
|
using ForwarderType = void (CancelableCallbackImpl::*)(Args...);
|
||||||
|
ForwarderType forwarder = &CancelableCallbackImpl::ForwardOnce;
|
||||||
|
*out = BindOnce(forwarder, weak_ptr_factory_.GetWeakPtr());
|
||||||
|
}
|
||||||
|
|
||||||
// The wrapper closure.
|
template <typename... Args>
|
||||||
base::Callback<void(void)> forwarder_;
|
void ForwardRepeating(Args... args) {
|
||||||
|
callback_.Run(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
void ForwardOnce(Args... args) {
|
||||||
|
weak_ptr_factory_.InvalidateWeakPtrs();
|
||||||
|
std::move(callback_).Run(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
// The stored closure that may be cancelled.
|
// The stored closure that may be cancelled.
|
||||||
base::Callback<void(void)> callback_;
|
CallbackType callback_;
|
||||||
|
mutable base::WeakPtrFactory<CancelableCallbackImpl> weak_ptr_factory_{this};
|
||||||
DISALLOW_COPY_AND_ASSIGN(CancelableCallback);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename A1>
|
} // namespace internal
|
||||||
class CancelableCallback<void(A1)> {
|
|
||||||
public:
|
|
||||||
CancelableCallback() : weak_factory_(this) {}
|
|
||||||
|
|
||||||
// |callback| must not be null.
|
///
|
||||||
explicit CancelableCallback(const base::Callback<void(A1)>& callback)
|
/// Consider using base::WeakPtr directly instead of base::CancelableCallback
|
||||||
: weak_factory_(this), callback_(callback) {
|
/// for the task cancellation.
|
||||||
DCHECK(!callback.is_null());
|
///
|
||||||
InitializeForwarder();
|
template <typename Signature>
|
||||||
}
|
using CancelableOnceCallback =
|
||||||
|
internal::CancelableCallbackImpl<OnceCallback<Signature>>;
|
||||||
|
using CancelableOnceClosure = CancelableOnceCallback<void()>;
|
||||||
|
|
||||||
~CancelableCallback() {}
|
template <typename Signature>
|
||||||
|
using CancelableRepeatingCallback =
|
||||||
// Cancels and drops the reference to the wrapped callback.
|
internal::CancelableCallbackImpl<RepeatingCallback<Signature>>;
|
||||||
void Cancel() {
|
using CancelableRepeatingClosure = CancelableRepeatingCallback<void()>;
|
||||||
weak_factory_.InvalidateWeakPtrs();
|
|
||||||
forwarder_.Reset();
|
|
||||||
callback_.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the wrapped callback has been cancelled.
|
|
||||||
bool IsCancelled() const { return callback_.is_null(); }
|
|
||||||
|
|
||||||
// Sets |callback| as the closure that may be cancelled. |callback| may not
|
|
||||||
// be null. Outstanding and any previously wrapped callbacks are cancelled.
|
|
||||||
void Reset(const base::Callback<void(A1)>& callback) {
|
|
||||||
DCHECK(!callback.is_null());
|
|
||||||
|
|
||||||
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
|
||||||
Cancel();
|
|
||||||
|
|
||||||
// |forwarder_| is no longer valid after Cancel(), so re-bind.
|
|
||||||
InitializeForwarder();
|
|
||||||
|
|
||||||
callback_ = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a callback that can be disabled by calling Cancel().
|
|
||||||
const base::Callback<void(A1)>& callback() const { return forwarder_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
void Forward(A1 a1) const { callback_.Run(a1); }
|
|
||||||
|
|
||||||
// Helper method to bind |forwarder_| using a weak pointer from
|
|
||||||
// |weak_factory_|.
|
|
||||||
void InitializeForwarder() {
|
|
||||||
forwarder_ = base::Bind(&CancelableCallback<void(A1)>::Forward,
|
|
||||||
weak_factory_.GetWeakPtr());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to ensure Forward() is not run when this object is destroyed.
|
|
||||||
base::WeakPtrFactory<CancelableCallback<void(A1)>> weak_factory_;
|
|
||||||
|
|
||||||
// The wrapper closure.
|
|
||||||
base::Callback<void(A1)> forwarder_;
|
|
||||||
|
|
||||||
// The stored closure that may be cancelled.
|
|
||||||
base::Callback<void(A1)> callback_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CancelableCallback);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A1, typename A2>
|
|
||||||
class CancelableCallback<void(A1, A2)> {
|
|
||||||
public:
|
|
||||||
CancelableCallback() : weak_factory_(this) {}
|
|
||||||
|
|
||||||
// |callback| must not be null.
|
|
||||||
explicit CancelableCallback(const base::Callback<void(A1, A2)>& callback)
|
|
||||||
: weak_factory_(this), callback_(callback) {
|
|
||||||
DCHECK(!callback.is_null());
|
|
||||||
InitializeForwarder();
|
|
||||||
}
|
|
||||||
|
|
||||||
~CancelableCallback() {}
|
|
||||||
|
|
||||||
// Cancels and drops the reference to the wrapped callback.
|
|
||||||
void Cancel() {
|
|
||||||
weak_factory_.InvalidateWeakPtrs();
|
|
||||||
forwarder_.Reset();
|
|
||||||
callback_.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the wrapped callback has been cancelled.
|
|
||||||
bool IsCancelled() const { return callback_.is_null(); }
|
|
||||||
|
|
||||||
// Sets |callback| as the closure that may be cancelled. |callback| may not
|
|
||||||
// be null. Outstanding and any previously wrapped callbacks are cancelled.
|
|
||||||
void Reset(const base::Callback<void(A1, A2)>& callback) {
|
|
||||||
DCHECK(!callback.is_null());
|
|
||||||
|
|
||||||
// Outstanding tasks (e.g., posted to a message loop) must not be called.
|
|
||||||
Cancel();
|
|
||||||
|
|
||||||
// |forwarder_| is no longer valid after Cancel(), so re-bind.
|
|
||||||
InitializeForwarder();
|
|
||||||
|
|
||||||
callback_ = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a callback that can be disabled by calling Cancel().
|
|
||||||
const base::Callback<void(A1, A2)>& callback() const { return forwarder_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
void Forward(A1 a1, A2 a2) const { callback_.Run(a1, a2); }
|
|
||||||
|
|
||||||
// Helper method to bind |forwarder_| using a weak pointer from
|
|
||||||
// |weak_factory_|.
|
|
||||||
void InitializeForwarder() {
|
|
||||||
forwarder_ = base::Bind(&CancelableCallback<void(A1, A2)>::Forward,
|
|
||||||
weak_factory_.GetWeakPtr());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to ensure Forward() is not run when this object is destroyed.
|
|
||||||
base::WeakPtrFactory<CancelableCallback<void(A1, A2)>> weak_factory_;
|
|
||||||
|
|
||||||
// The wrapper closure.
|
|
||||||
base::Callback<void(A1, A2)> forwarder_;
|
|
||||||
|
|
||||||
// The stored closure that may be cancelled.
|
|
||||||
base::Callback<void(A1, A2)> callback_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CancelableCallback);
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef CancelableCallback<void(void)> CancelableClosure;
|
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
382
include/base/cef_compiler_specific.h
Normal file
382
include/base/cef_compiler_specific.h
Normal file
@@ -0,0 +1,382 @@
|
|||||||
|
// Copyright (c) 2021 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||||
|
// Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/compiler_specific.h"
|
||||||
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
|
// The following is substantially similar to the Chromium implementation.
|
||||||
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
|
// updated to match.
|
||||||
|
|
||||||
|
#include "include/base/cef_build.h"
|
||||||
|
|
||||||
|
// This is a wrapper around `__has_cpp_attribute`, which can be used to test for
|
||||||
|
// the presence of an attribute. In case the compiler does not support this
|
||||||
|
// macro it will simply evaluate to 0.
|
||||||
|
//
|
||||||
|
// References:
|
||||||
|
// https://wg21.link/sd6#testing-for-the-presence-of-an-attribute-__has_cpp_attribute
|
||||||
|
// https://wg21.link/cpp.cond#:__has_cpp_attribute
|
||||||
|
#if defined(__has_cpp_attribute)
|
||||||
|
#define HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
||||||
|
#else
|
||||||
|
#define HAS_CPP_ATTRIBUTE(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// A wrapper around `__has_builtin`, similar to HAS_CPP_ATTRIBUTE.
|
||||||
|
#if defined(__has_builtin)
|
||||||
|
#define HAS_BUILTIN(x) __has_builtin(x)
|
||||||
|
#else
|
||||||
|
#define HAS_BUILTIN(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// __has_feature and __has_attribute don't exist for MSVC.
|
||||||
|
#if !defined(__has_feature)
|
||||||
|
#define __has_feature(x) 0
|
||||||
|
#endif // !defined(__has_feature)
|
||||||
|
|
||||||
|
#if !defined(__has_attribute)
|
||||||
|
#define __has_attribute(x) 0
|
||||||
|
#endif // !defined(__has_attribute)
|
||||||
|
|
||||||
|
// Annotate a function indicating it should not be inlined.
|
||||||
|
// Use like:
|
||||||
|
// NOINLINE void DoStuff() { ... }
|
||||||
|
#if defined(COMPILER_GCC)
|
||||||
|
#define NOINLINE __attribute__((noinline))
|
||||||
|
#elif defined(COMPILER_MSVC)
|
||||||
|
#define NOINLINE __declspec(noinline)
|
||||||
|
#else
|
||||||
|
#define NOINLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(COMPILER_GCC) && defined(NDEBUG)
|
||||||
|
#define ALWAYS_INLINE inline __attribute__((__always_inline__))
|
||||||
|
#elif defined(COMPILER_MSVC) && defined(NDEBUG)
|
||||||
|
#define ALWAYS_INLINE __forceinline
|
||||||
|
#else
|
||||||
|
#define ALWAYS_INLINE inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Annotate a function indicating it should never be tail called. Useful to make
|
||||||
|
// sure callers of the annotated function are never omitted from call-stacks.
|
||||||
|
// To provide the complementary behavior (prevent the annotated function from
|
||||||
|
// being omitted) look at NOINLINE. Also note that this doesn't prevent code
|
||||||
|
// folding of multiple identical caller functions into a single signature. To
|
||||||
|
// prevent code folding, see NO_CODE_FOLDING() in base/debug/alias.h.
|
||||||
|
// Use like:
|
||||||
|
// void NOT_TAIL_CALLED FooBar();
|
||||||
|
#if defined(__clang__) && __has_attribute(not_tail_called)
|
||||||
|
#define NOT_TAIL_CALLED __attribute__((not_tail_called))
|
||||||
|
#else
|
||||||
|
#define NOT_TAIL_CALLED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Specify memory alignment for structs, classes, etc.
|
||||||
|
// Use like:
|
||||||
|
// class ALIGNAS(16) MyClass { ... }
|
||||||
|
// ALIGNAS(16) int array[4];
|
||||||
|
//
|
||||||
|
// In most places you can use the C++11 keyword "alignas", which is preferred.
|
||||||
|
//
|
||||||
|
// But compilers have trouble mixing __attribute__((...)) syntax with
|
||||||
|
// alignas(...) syntax.
|
||||||
|
//
|
||||||
|
// Doesn't work in clang or gcc:
|
||||||
|
// struct alignas(16) __attribute__((packed)) S { char c; };
|
||||||
|
// Works in clang but not gcc:
|
||||||
|
// struct __attribute__((packed)) alignas(16) S2 { char c; };
|
||||||
|
// Works in clang and gcc:
|
||||||
|
// struct alignas(16) S3 { char c; } __attribute__((packed));
|
||||||
|
//
|
||||||
|
// There are also some attributes that must be specified *before* a class
|
||||||
|
// definition: visibility (used for exporting functions/classes) is one of
|
||||||
|
// these attributes. This means that it is not possible to use alignas() with a
|
||||||
|
// class that is marked as exported.
|
||||||
|
#if defined(COMPILER_MSVC)
|
||||||
|
#define ALIGNAS(byte_alignment) __declspec(align(byte_alignment))
|
||||||
|
#elif defined(COMPILER_GCC)
|
||||||
|
#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// In case the compiler supports it NO_UNIQUE_ADDRESS evaluates to the C++20
|
||||||
|
// attribute [[no_unique_address]]. This allows annotating data members so that
|
||||||
|
// they need not have an address distinct from all other non-static data members
|
||||||
|
// of its class.
|
||||||
|
//
|
||||||
|
// References:
|
||||||
|
// * https://en.cppreference.com/w/cpp/language/attributes/no_unique_address
|
||||||
|
// * https://wg21.link/dcl.attr.nouniqueaddr
|
||||||
|
#if HAS_CPP_ATTRIBUTE(no_unique_address)
|
||||||
|
#define NO_UNIQUE_ADDRESS [[no_unique_address]]
|
||||||
|
#else
|
||||||
|
#define NO_UNIQUE_ADDRESS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Tell the compiler a function is using a printf-style format string.
|
||||||
|
// |format_param| is the one-based index of the format string parameter;
|
||||||
|
// |dots_param| is the one-based index of the "..." parameter.
|
||||||
|
// For v*printf functions (which take a va_list), pass 0 for dots_param.
|
||||||
|
// (This is undocumented but matches what the system C headers do.)
|
||||||
|
// For member functions, the implicit this parameter counts as index 1.
|
||||||
|
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||||
|
#define PRINTF_FORMAT(format_param, dots_param) \
|
||||||
|
__attribute__((format(printf, format_param, dots_param)))
|
||||||
|
#else
|
||||||
|
#define PRINTF_FORMAT(format_param, dots_param)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// WPRINTF_FORMAT is the same, but for wide format strings.
|
||||||
|
// This doesn't appear to yet be implemented in any compiler.
|
||||||
|
// See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 .
|
||||||
|
#define WPRINTF_FORMAT(format_param, dots_param)
|
||||||
|
// If available, it would look like:
|
||||||
|
// __attribute__((format(wprintf, format_param, dots_param)))
|
||||||
|
|
||||||
|
// Sanitizers annotations.
|
||||||
|
#if defined(__has_attribute)
|
||||||
|
#if __has_attribute(no_sanitize)
|
||||||
|
#define NO_SANITIZE(what) __attribute__((no_sanitize(what)))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if !defined(NO_SANITIZE)
|
||||||
|
#define NO_SANITIZE(what)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// MemorySanitizer annotations.
|
||||||
|
#if defined(MEMORY_SANITIZER) && !defined(OS_NACL)
|
||||||
|
#include <sanitizer/msan_interface.h>
|
||||||
|
|
||||||
|
// Mark a memory region fully initialized.
|
||||||
|
// Use this to annotate code that deliberately reads uninitialized data, for
|
||||||
|
// example a GC scavenging root set pointers from the stack.
|
||||||
|
#define MSAN_UNPOISON(p, size) __msan_unpoison(p, size)
|
||||||
|
|
||||||
|
// Check a memory region for initializedness, as if it was being used here.
|
||||||
|
// If any bits are uninitialized, crash with an MSan report.
|
||||||
|
// Use this to sanitize data which MSan won't be able to track, e.g. before
|
||||||
|
// passing data to another process via shared memory.
|
||||||
|
#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) \
|
||||||
|
__msan_check_mem_is_initialized(p, size)
|
||||||
|
#else // MEMORY_SANITIZER
|
||||||
|
#define MSAN_UNPOISON(p, size)
|
||||||
|
#define MSAN_CHECK_MEM_IS_INITIALIZED(p, size)
|
||||||
|
#endif // MEMORY_SANITIZER
|
||||||
|
|
||||||
|
// DISABLE_CFI_PERF -- Disable Control Flow Integrity for perf reasons.
|
||||||
|
#if !defined(DISABLE_CFI_PERF)
|
||||||
|
#if defined(__clang__) && defined(OFFICIAL_BUILD)
|
||||||
|
#define DISABLE_CFI_PERF __attribute__((no_sanitize("cfi")))
|
||||||
|
#else
|
||||||
|
#define DISABLE_CFI_PERF
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// DISABLE_CFI_ICALL -- Disable Control Flow Integrity indirect call checks.
|
||||||
|
#if !defined(DISABLE_CFI_ICALL)
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
// Windows also needs __declspec(guard(nocf)).
|
||||||
|
#define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall") __declspec(guard(nocf))
|
||||||
|
#else
|
||||||
|
#define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall")
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if !defined(DISABLE_CFI_ICALL)
|
||||||
|
#define DISABLE_CFI_ICALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Macro useful for writing cross-platform function pointers.
|
||||||
|
#if !defined(CDECL)
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#define CDECL __cdecl
|
||||||
|
#else // defined(OS_WIN)
|
||||||
|
#define CDECL
|
||||||
|
#endif // defined(OS_WIN)
|
||||||
|
#endif // !defined(CDECL)
|
||||||
|
|
||||||
|
// Macro for hinting that an expression is likely to be false.
|
||||||
|
#if !defined(UNLIKELY)
|
||||||
|
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||||
|
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||||
|
#else
|
||||||
|
#define UNLIKELY(x) (x)
|
||||||
|
#endif // defined(COMPILER_GCC)
|
||||||
|
#endif // !defined(UNLIKELY)
|
||||||
|
|
||||||
|
#if !defined(LIKELY)
|
||||||
|
#if defined(COMPILER_GCC) || defined(__clang__)
|
||||||
|
#define LIKELY(x) __builtin_expect(!!(x), 1)
|
||||||
|
#else
|
||||||
|
#define LIKELY(x) (x)
|
||||||
|
#endif // defined(COMPILER_GCC)
|
||||||
|
#endif // !defined(LIKELY)
|
||||||
|
|
||||||
|
// Compiler feature-detection.
|
||||||
|
// clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension
|
||||||
|
#if defined(__has_feature)
|
||||||
|
#define HAS_FEATURE(FEATURE) __has_feature(FEATURE)
|
||||||
|
#else
|
||||||
|
#define HAS_FEATURE(FEATURE) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(COMPILER_GCC)
|
||||||
|
#define PRETTY_FUNCTION __PRETTY_FUNCTION__
|
||||||
|
#elif defined(COMPILER_MSVC)
|
||||||
|
#define PRETTY_FUNCTION __FUNCSIG__
|
||||||
|
#else
|
||||||
|
// See https://en.cppreference.com/w/c/language/function_definition#func
|
||||||
|
#define PRETTY_FUNCTION __func__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(CPU_ARM_NEON)
|
||||||
|
#if defined(__arm__)
|
||||||
|
#if !defined(__ARMEB__) && !defined(__ARM_EABI__) && !defined(__EABI__) && \
|
||||||
|
!defined(__VFP_FP__) && !defined(_WIN32_WCE) && !defined(ANDROID)
|
||||||
|
#error Chromium does not support middle endian architecture
|
||||||
|
#endif
|
||||||
|
#if defined(__ARM_NEON__)
|
||||||
|
#define CPU_ARM_NEON 1
|
||||||
|
#endif
|
||||||
|
#endif // defined(__arm__)
|
||||||
|
#endif // !defined(CPU_ARM_NEON)
|
||||||
|
|
||||||
|
#if !defined(HAVE_MIPS_MSA_INTRINSICS)
|
||||||
|
#if defined(__mips_msa) && defined(__mips_isa_rev) && (__mips_isa_rev >= 5)
|
||||||
|
#define HAVE_MIPS_MSA_INTRINSICS 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__) && __has_attribute(uninitialized)
|
||||||
|
// Attribute "uninitialized" disables -ftrivial-auto-var-init=pattern for
|
||||||
|
// the specified variable.
|
||||||
|
// Library-wide alternative is
|
||||||
|
// 'configs -= [ "//build/config/compiler:default_init_stack_vars" ]' in .gn
|
||||||
|
// file.
|
||||||
|
//
|
||||||
|
// See "init_stack_vars" in build/config/compiler/BUILD.gn and
|
||||||
|
// http://crbug.com/977230
|
||||||
|
// "init_stack_vars" is enabled for non-official builds and we hope to enable it
|
||||||
|
// in official build in 2020 as well. The flag writes fixed pattern into
|
||||||
|
// uninitialized parts of all local variables. In rare cases such initialization
|
||||||
|
// is undesirable and attribute can be used:
|
||||||
|
// 1. Degraded performance
|
||||||
|
// In most cases compiler is able to remove additional stores. E.g. if memory is
|
||||||
|
// never accessed or properly initialized later. Preserved stores mostly will
|
||||||
|
// not affect program performance. However if compiler failed on some
|
||||||
|
// performance critical code we can get a visible regression in a benchmark.
|
||||||
|
// 2. memset, memcpy calls
|
||||||
|
// Compiler may replaces some memory writes with memset or memcpy calls. This is
|
||||||
|
// not -ftrivial-auto-var-init specific, but it can happen more likely with the
|
||||||
|
// flag. It can be a problem if code is not linked with C run-time library.
|
||||||
|
//
|
||||||
|
// Note: The flag is security risk mitigation feature. So in future the
|
||||||
|
// attribute uses should be avoided when possible. However to enable this
|
||||||
|
// mitigation on the most of the code we need to be less strict now and minimize
|
||||||
|
// number of exceptions later. So if in doubt feel free to use attribute, but
|
||||||
|
// please document the problem for someone who is going to cleanup it later.
|
||||||
|
// E.g. platform, bot, benchmark or test name in patch description or next to
|
||||||
|
// the attribute.
|
||||||
|
#define STACK_UNINITIALIZED __attribute__((uninitialized))
|
||||||
|
#else
|
||||||
|
#define STACK_UNINITIALIZED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// The ANALYZER_ASSUME_TRUE(bool arg) macro adds compiler-specific hints
|
||||||
|
// to Clang which control what code paths are statically analyzed,
|
||||||
|
// and is meant to be used in conjunction with assert & assert-like functions.
|
||||||
|
// The expression is passed straight through if analysis isn't enabled.
|
||||||
|
//
|
||||||
|
// ANALYZER_SKIP_THIS_PATH() suppresses static analysis for the current
|
||||||
|
// codepath and any other branching codepaths that might follow.
|
||||||
|
#if defined(__clang_analyzer__)
|
||||||
|
|
||||||
|
inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline constexpr bool AnalyzerAssumeTrue(bool arg) {
|
||||||
|
// AnalyzerNoReturn() is invoked and analysis is terminated if |arg| is
|
||||||
|
// false.
|
||||||
|
return arg || AnalyzerNoReturn();
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ANALYZER_ASSUME_TRUE(arg) ::AnalyzerAssumeTrue(!!(arg))
|
||||||
|
#define ANALYZER_SKIP_THIS_PATH() static_cast<void>(::AnalyzerNoReturn())
|
||||||
|
#define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var);
|
||||||
|
|
||||||
|
#else // !defined(__clang_analyzer__)
|
||||||
|
|
||||||
|
#define ANALYZER_ASSUME_TRUE(arg) (arg)
|
||||||
|
#define ANALYZER_SKIP_THIS_PATH()
|
||||||
|
#define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var);
|
||||||
|
|
||||||
|
#endif // defined(__clang_analyzer__)
|
||||||
|
|
||||||
|
// Use nomerge attribute to disable optimization of merging multiple same calls.
|
||||||
|
#if defined(__clang__) && __has_attribute(nomerge)
|
||||||
|
#define NOMERGE [[clang::nomerge]]
|
||||||
|
#else
|
||||||
|
#define NOMERGE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Marks a type as being eligible for the "trivial" ABI despite having a
|
||||||
|
// non-trivial destructor or copy/move constructor. Such types can be relocated
|
||||||
|
// after construction by simply copying their memory, which makes them eligible
|
||||||
|
// to be passed in registers. The canonical example is std::unique_ptr.
|
||||||
|
//
|
||||||
|
// Use with caution; this has some subtle effects on constructor/destructor
|
||||||
|
// ordering and will be very incorrect if the type relies on its address
|
||||||
|
// remaining constant. When used as a function argument (by value), the value
|
||||||
|
// may be constructed in the caller's stack frame, passed in a register, and
|
||||||
|
// then used and destructed in the callee's stack frame. A similar thing can
|
||||||
|
// occur when values are returned.
|
||||||
|
//
|
||||||
|
// TRIVIAL_ABI is not needed for types which have a trivial destructor and
|
||||||
|
// copy/move constructors, such as base::TimeTicks and other POD.
|
||||||
|
//
|
||||||
|
// It is also not likely to be effective on types too large to be passed in one
|
||||||
|
// or two registers on typical target ABIs.
|
||||||
|
//
|
||||||
|
// See also:
|
||||||
|
// https://clang.llvm.org/docs/AttributeReference.html#trivial-abi
|
||||||
|
// https://libcxx.llvm.org/docs/DesignDocs/UniquePtrTrivialAbi.html
|
||||||
|
#if defined(__clang__) && __has_attribute(trivial_abi)
|
||||||
|
#define TRIVIAL_ABI [[clang::trivial_abi]]
|
||||||
|
#else
|
||||||
|
#define TRIVIAL_ABI
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_COMPILER_SPECIFIC_H_
|
||||||
76
include/base/cef_dump_without_crashing.h
Normal file
76
include/base/cef_dump_without_crashing.h
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
// Copyright (c) 2024 Marshall A. Greenblatt. Portions copyright (c) 2012
|
||||||
|
// Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
///
|
||||||
|
/// \file
|
||||||
|
/// Provides functions for generating crash dumps.
|
||||||
|
///
|
||||||
|
/// NOTE: The contents of this file are only available to applications that link
|
||||||
|
/// against the libcef_dll_wrapper target.
|
||||||
|
///
|
||||||
|
/// NOTE: Ensure crash reporting is configured before use. See
|
||||||
|
/// https://bitbucket.org/chromiumembedded/cef/wiki/CrashReporting.md for more
|
||||||
|
/// information
|
||||||
|
///
|
||||||
|
/// WARNING: Crash reporting should not be used in the main/browser process
|
||||||
|
/// before calling CefInitialize or in sub-processes before CefExecuteProcess.
|
||||||
|
///
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_DUMP_WITHOUT_CRASHING_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_DUMP_WITHOUT_CRASHING_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
constexpr long long kOneDayInMilliseconds = 86400000;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// CefDumpWithoutCrashing allows for generating crash dumps with a throttling
|
||||||
|
/// mechanism, preventing frequent dumps from being generated in a short period
|
||||||
|
/// of time from the same location. The |function_name|, |file_name|, and
|
||||||
|
/// |line_number| determine the location of the dump. The
|
||||||
|
/// |mseconds_between_dumps| is an interval between consecutive dumps in
|
||||||
|
/// milliseconds from the same location.
|
||||||
|
///
|
||||||
|
/// Returns true if the dump was successfully generated, false otherwise.
|
||||||
|
///
|
||||||
|
bool CefDumpWithoutCrashing(
|
||||||
|
long long mseconds_between_dumps = kOneDayInMilliseconds,
|
||||||
|
const char* function_name = __builtin_FUNCTION(),
|
||||||
|
const char* file_name = __builtin_FILE(),
|
||||||
|
int line_number = __builtin_LINE());
|
||||||
|
|
||||||
|
///
|
||||||
|
/// CefDumpWithoutCrashingUnthrottled allows for immediate crash dumping without
|
||||||
|
/// any throttling constraints.
|
||||||
|
///
|
||||||
|
/// Returns true if the dump was successfully generated, false otherwise.
|
||||||
|
///
|
||||||
|
bool CefDumpWithoutCrashingUnthrottled();
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_DUMP_WITHOUT_CRASHING_H_
|
||||||
@@ -32,12 +32,7 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_LOCK_H_
|
#define CEF_INCLUDE_BASE_CEF_LOCK_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_SYNCHRONIZATION_LOCK_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/synchronization/lock.h"
|
#include "base/synchronization/lock.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -46,28 +41,35 @@
|
|||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/cef_macros.h"
|
|
||||||
#include "include/base/cef_platform_thread.h"
|
#include "include/base/cef_platform_thread.h"
|
||||||
#include "include/base/internal/cef_lock_impl.h"
|
#include "include/base/internal/cef_lock_impl.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace cef_internal {
|
namespace cef_internal {
|
||||||
|
|
||||||
// A convenient wrapper for an OS specific critical section. The only real
|
///
|
||||||
// intelligence in this class is in debug mode for the support for the
|
/// A convenient wrapper for an OS specific critical section. The only real
|
||||||
// AssertAcquired() method.
|
/// intelligence in this class is in debug mode for the support for the
|
||||||
|
/// AssertAcquired() method.
|
||||||
|
///
|
||||||
class Lock {
|
class Lock {
|
||||||
public:
|
public:
|
||||||
#if !DCHECK_IS_ON() // Optimized wrapper implementation
|
#if !DCHECK_IS_ON() // Optimized wrapper implementation
|
||||||
Lock() : lock_() {}
|
Lock() : lock_() {}
|
||||||
|
|
||||||
|
Lock(const Lock&) = delete;
|
||||||
|
Lock& operator=(const Lock&) = delete;
|
||||||
|
|
||||||
~Lock() {}
|
~Lock() {}
|
||||||
void Acquire() { lock_.Lock(); }
|
void Acquire() { lock_.Lock(); }
|
||||||
void Release() { lock_.Unlock(); }
|
void Release() { lock_.Unlock(); }
|
||||||
|
|
||||||
// If the lock is not held, take it and return true. If the lock is already
|
///
|
||||||
// held by another thread, immediately return false. This must not be called
|
/// If the lock is not held, take it and return true. If the lock is already
|
||||||
// by a thread already holding the lock (what happens is undefined and an
|
/// held by another thread, immediately return false. This must not be called
|
||||||
// assertion may fail).
|
/// by a thread already holding the lock (what happens is undefined and an
|
||||||
|
/// assertion may fail).
|
||||||
|
///
|
||||||
bool Try() { return lock_.Try(); }
|
bool Try() { return lock_.Try(); }
|
||||||
|
|
||||||
// Null implementation if not debug.
|
// Null implementation if not debug.
|
||||||
@@ -116,11 +118,11 @@ class Lock {
|
|||||||
|
|
||||||
// Platform specific underlying lock implementation.
|
// Platform specific underlying lock implementation.
|
||||||
LockImpl lock_;
|
LockImpl lock_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Lock);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A helper class that acquires the given Lock while the AutoLock is in scope.
|
///
|
||||||
|
/// A helper class that acquires the given Lock while the AutoLock is in scope.
|
||||||
|
///
|
||||||
class AutoLock {
|
class AutoLock {
|
||||||
public:
|
public:
|
||||||
struct AlreadyAcquired {};
|
struct AlreadyAcquired {};
|
||||||
@@ -131,6 +133,9 @@ class AutoLock {
|
|||||||
lock_.AssertAcquired();
|
lock_.AssertAcquired();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutoLock(const AutoLock&) = delete;
|
||||||
|
AutoLock& operator=(const AutoLock&) = delete;
|
||||||
|
|
||||||
~AutoLock() {
|
~AutoLock() {
|
||||||
lock_.AssertAcquired();
|
lock_.AssertAcquired();
|
||||||
lock_.Release();
|
lock_.Release();
|
||||||
@@ -138,11 +143,12 @@ class AutoLock {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Lock& lock_;
|
Lock& lock_;
|
||||||
DISALLOW_COPY_AND_ASSIGN(AutoLock);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// AutoUnlock is a helper that will Release() the |lock| argument in the
|
///
|
||||||
// constructor, and re-Acquire() it in the destructor.
|
/// AutoUnlock is a helper that will Release() the |lock| argument in the
|
||||||
|
/// constructor, and re-Acquire() it in the destructor.
|
||||||
|
///
|
||||||
class AutoUnlock {
|
class AutoUnlock {
|
||||||
public:
|
public:
|
||||||
explicit AutoUnlock(Lock& lock) : lock_(lock) {
|
explicit AutoUnlock(Lock& lock) : lock_(lock) {
|
||||||
@@ -151,11 +157,13 @@ class AutoUnlock {
|
|||||||
lock_.Release();
|
lock_.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutoUnlock(const AutoUnlock&) = delete;
|
||||||
|
AutoUnlock& operator=(const AutoUnlock&) = delete;
|
||||||
|
|
||||||
~AutoUnlock() { lock_.Acquire(); }
|
~AutoUnlock() { lock_.Acquire(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Lock& lock_;
|
Lock& lock_;
|
||||||
DISALLOW_COPY_AND_ASSIGN(AutoUnlock);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cef_internal
|
} // namespace cef_internal
|
||||||
@@ -163,9 +171,9 @@ class AutoUnlock {
|
|||||||
// Implement classes in the cef_internal namespace and then expose them to the
|
// Implement classes in the cef_internal namespace and then expose them to the
|
||||||
// base namespace. This avoids conflicts with the base.lib implementation when
|
// base namespace. This avoids conflicts with the base.lib implementation when
|
||||||
// linking sandbox support on Windows.
|
// linking sandbox support on Windows.
|
||||||
using cef_internal::Lock;
|
|
||||||
using cef_internal::AutoLock;
|
using cef_internal::AutoLock;
|
||||||
using cef_internal::AutoUnlock;
|
using cef_internal::AutoUnlock;
|
||||||
|
using cef_internal::Lock;
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
@@ -27,116 +27,140 @@
|
|||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
|
||||||
// ---------------------------------------------------------------------------
|
///
|
||||||
//
|
/// \file
|
||||||
// The contents of this file are only available to applications that link
|
/// A bunch of macros for logging.
|
||||||
// against the libcef_dll_wrapper target.
|
///
|
||||||
//
|
/// NOTE: The contents of this file are only available to applications that link
|
||||||
// WARNING: Logging macros should not be used in the main/browser process before
|
/// against the libcef_dll_wrapper target.
|
||||||
// calling CefInitialize or in sub-processes before calling CefExecuteProcess.
|
///
|
||||||
//
|
/// WARNING: Logging macros should not be used in the main/browser process
|
||||||
// Instructions
|
/// before calling CefInitialize or in sub-processes before calling
|
||||||
// ------------
|
/// CefExecuteProcess.
|
||||||
//
|
///
|
||||||
// Make a bunch of macros for logging. The way to log things is to stream
|
/// INSTRUCTIONS:
|
||||||
// things to LOG(<a particular severity level>). E.g.,
|
///
|
||||||
//
|
/// The way to log things is to stream things to LOG(<a particular severity
|
||||||
// LOG(INFO) << "Found " << num_cookies << " cookies";
|
/// level>). E.g.,
|
||||||
//
|
///
|
||||||
// You can also do conditional logging:
|
/// <pre>
|
||||||
//
|
/// LOG(INFO) << "Found " << num_cookies << " cookies";
|
||||||
// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
/// </pre>
|
||||||
//
|
///
|
||||||
// The CHECK(condition) macro is active in both debug and release builds and
|
/// You can also do conditional logging:
|
||||||
// effectively performs a LOG(FATAL) which terminates the process and
|
///
|
||||||
// generates a crashdump unless a debugger is attached.
|
/// <pre>
|
||||||
//
|
/// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||||
// There are also "debug mode" logging macros like the ones above:
|
/// </pre>
|
||||||
//
|
///
|
||||||
// DLOG(INFO) << "Found cookies";
|
/// The CHECK(condition) macro is active in both debug and release builds and
|
||||||
//
|
/// effectively performs a LOG(FATAL) which terminates the process and
|
||||||
// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
/// generates a crashdump unless a debugger is attached.
|
||||||
//
|
///
|
||||||
// All "debug mode" logging is compiled away to nothing for non-debug mode
|
/// There are also "debug mode" logging macros like the ones above:
|
||||||
// compiles. LOG_IF and development flags also work well together
|
///
|
||||||
// because the code can be compiled away sometimes.
|
/// <pre>
|
||||||
//
|
/// DLOG(INFO) << "Found cookies";
|
||||||
// We also have
|
///
|
||||||
//
|
/// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||||
// LOG_ASSERT(assertion);
|
/// </pre>
|
||||||
// DLOG_ASSERT(assertion);
|
///
|
||||||
//
|
/// All "debug mode" logging is compiled away to nothing for non-debug mode
|
||||||
// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion;
|
/// compiles. LOG_IF and development flags also work well together
|
||||||
//
|
/// because the code can be compiled away sometimes.
|
||||||
// There are "verbose level" logging macros. They look like
|
///
|
||||||
//
|
/// We also have
|
||||||
// VLOG(1) << "I'm printed when you run the program with --v=1 or more";
|
///
|
||||||
// VLOG(2) << "I'm printed when you run the program with --v=2 or more";
|
/// <pre>
|
||||||
//
|
/// LOG_ASSERT(assertion);
|
||||||
// These always log at the INFO log level (when they log at all).
|
/// DLOG_ASSERT(assertion);
|
||||||
// The verbose logging can also be turned on module-by-module. For instance,
|
/// </pre>
|
||||||
// --vmodule=profile=2,icon_loader=1,browser_*=3,*/chromeos/*=4 --v=0
|
///
|
||||||
// will cause:
|
/// which is syntactic sugar for "{,D}LOG_IF(FATAL, assert fails) << assertion;"
|
||||||
// a. VLOG(2) and lower messages to be printed from profile.{h,cc}
|
///
|
||||||
// b. VLOG(1) and lower messages to be printed from icon_loader.{h,cc}
|
/// There are "verbose level" logging macros. They look like
|
||||||
// c. VLOG(3) and lower messages to be printed from files prefixed with
|
///
|
||||||
// "browser"
|
/// <pre>
|
||||||
// d. VLOG(4) and lower messages to be printed from files under a
|
/// VLOG(1) << "I'm printed when you run the program with --v=1 or more";
|
||||||
// "chromeos" directory.
|
/// VLOG(2) << "I'm printed when you run the program with --v=2 or more";
|
||||||
// e. VLOG(0) and lower messages to be printed from elsewhere
|
/// </pre>
|
||||||
//
|
///
|
||||||
// The wildcarding functionality shown by (c) supports both '*' (match
|
/// These always log at the INFO log level (when they log at all).
|
||||||
// 0 or more characters) and '?' (match any single character)
|
/// The verbose logging can also be turned on module-by-module. For instance,
|
||||||
// wildcards. Any pattern containing a forward or backward slash will
|
/// <pre>
|
||||||
// be tested against the whole pathname and not just the module.
|
/// --vmodule=profile=2,icon_loader=1,browser_*=3,*/chromeos/*=4 --v=0
|
||||||
// E.g., "*/foo/bar/*=2" would change the logging level for all code
|
/// </pre>
|
||||||
// in source files under a "foo/bar" directory.
|
/// will cause:
|
||||||
//
|
/// 1. VLOG(2) and lower messages to be printed from profile.{h,cc}
|
||||||
// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as
|
/// 2. VLOG(1) and lower messages to be printed from icon_loader.{h,cc}
|
||||||
//
|
/// 3. VLOG(3) and lower messages to be printed from files prefixed with
|
||||||
// if (VLOG_IS_ON(2)) {
|
/// "browser"
|
||||||
// // do some logging preparation and logging
|
/// 4. VLOG(4) and lower messages to be printed from files under a
|
||||||
// // that can't be accomplished with just VLOG(2) << ...;
|
/// "chromeos" directory.
|
||||||
// }
|
/// 5. VLOG(0) and lower messages to be printed from elsewhere
|
||||||
//
|
///
|
||||||
// There is also a VLOG_IF "verbose level" condition macro for sample
|
/// The wildcarding functionality shown by (c) supports both '*' (match
|
||||||
// cases, when some extra computation and preparation for logs is not
|
/// 0 or more characters) and '?' (match any single character)
|
||||||
// needed.
|
/// wildcards. Any pattern containing a forward or backward slash will
|
||||||
//
|
/// be tested against the whole pathname and not just the module.
|
||||||
// VLOG_IF(1, (size > 1024))
|
/// E.g., "*/foo/bar/*=2" would change the logging level for all code
|
||||||
// << "I'm printed when size is more than 1024 and when you run the "
|
/// in source files under a "foo/bar" directory.
|
||||||
// "program with --v=1 or more";
|
///
|
||||||
//
|
/// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as
|
||||||
// We also override the standard 'assert' to use 'DLOG_ASSERT'.
|
///
|
||||||
//
|
/// <pre>
|
||||||
// Lastly, there is:
|
/// if (VLOG_IS_ON(2)) {
|
||||||
//
|
/// // do some logging preparation and logging
|
||||||
// PLOG(ERROR) << "Couldn't do foo";
|
/// // that can't be accomplished with just VLOG(2) << ...;
|
||||||
// DPLOG(ERROR) << "Couldn't do foo";
|
/// }
|
||||||
// PLOG_IF(ERROR, cond) << "Couldn't do foo";
|
/// </pre>
|
||||||
// DPLOG_IF(ERROR, cond) << "Couldn't do foo";
|
///
|
||||||
// PCHECK(condition) << "Couldn't do foo";
|
/// There is also a VLOG_IF "verbose level" condition macro for sample
|
||||||
// DPCHECK(condition) << "Couldn't do foo";
|
/// cases, when some extra computation and preparation for logs is not
|
||||||
//
|
/// needed.
|
||||||
// which append the last system error to the message in string form (taken from
|
///
|
||||||
// GetLastError() on Windows and errno on POSIX).
|
/// <pre>
|
||||||
//
|
/// VLOG_IF(1, (size > 1024))
|
||||||
// The supported severity levels for macros that allow you to specify one
|
/// << "I'm printed when size is more than 1024 and when you run the "
|
||||||
// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
|
/// "program with --v=1 or more";
|
||||||
//
|
/// </pre>
|
||||||
// Very important: logging a message at the FATAL severity level causes
|
///
|
||||||
// the program to terminate (after the message is logged).
|
/// We also override the standard 'assert' to use 'DLOG_ASSERT'.
|
||||||
//
|
///
|
||||||
// There is the special severity of DFATAL, which logs FATAL in debug mode,
|
/// Lastly, there is:
|
||||||
// ERROR in normal mode.
|
///
|
||||||
//
|
/// <pre>
|
||||||
|
/// PLOG(ERROR) << "Couldn't do foo";
|
||||||
|
/// DPLOG(ERROR) << "Couldn't do foo";
|
||||||
|
/// PLOG_IF(ERROR, cond) << "Couldn't do foo";
|
||||||
|
/// DPLOG_IF(ERROR, cond) << "Couldn't do foo";
|
||||||
|
/// PCHECK(condition) << "Couldn't do foo";
|
||||||
|
/// DPCHECK(condition) << "Couldn't do foo";
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// which append the last system error to the message in string form (taken from
|
||||||
|
/// GetLastError() on Windows and errno on POSIX).
|
||||||
|
///
|
||||||
|
/// The supported severity levels for macros that allow you to specify one
|
||||||
|
/// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
|
||||||
|
///
|
||||||
|
/// Very important: logging a message at the FATAL severity level causes
|
||||||
|
/// the program to terminate (after the message is logged).
|
||||||
|
///
|
||||||
|
/// There is the special severity of DFATAL, which logs FATAL in debug mode,
|
||||||
|
/// ERROR in normal mode.
|
||||||
|
///
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
#define CEF_INCLUDE_BASE_CEF_LOGGING_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(DCHECK)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/logging.h"
|
||||||
|
#include "base/notreached.h"
|
||||||
|
#elif defined(DCHECK)
|
||||||
// Do nothing if the macros provided by this header already exist.
|
// Do nothing if the macros provided by this header already exist.
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
// This can happen in cases where Chromium code is used directly by the
|
||||||
// client application. When using Chromium code directly always include
|
// client application. When using Chromium code directly always include
|
||||||
@@ -144,15 +168,12 @@
|
|||||||
|
|
||||||
// Always define the DCHECK_IS_ON macro which is used from other CEF headers.
|
// Always define the DCHECK_IS_ON macro which is used from other CEF headers.
|
||||||
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
|
||||||
#define DCHECK_IS_ON() 0
|
#define DCHECK_IS_ON() false
|
||||||
#else
|
#else
|
||||||
#define DCHECK_IS_ON() 1
|
#define DCHECK_IS_ON() true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
#else // !defined(DCHECK)
|
||||||
// When building CEF include the Chromium header directly.
|
|
||||||
#include "base/logging.h"
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
@@ -163,7 +184,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "include/base/cef_build.h"
|
#include "include/base/cef_build.h"
|
||||||
#include "include/base/cef_macros.h"
|
|
||||||
#include "include/internal/cef_logging_internal.h"
|
#include "include/internal/cef_logging_internal.h"
|
||||||
|
|
||||||
namespace cef {
|
namespace cef {
|
||||||
@@ -201,21 +221,21 @@ const LogSeverity LOG_DFATAL = LOG_FATAL;
|
|||||||
// A few definitions of macros that don't generate much code. These are used
|
// A few definitions of macros that don't generate much code. These are used
|
||||||
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's
|
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's
|
||||||
// better to have compact code for these operations.
|
// better to have compact code for these operations.
|
||||||
#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \
|
||||||
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_INFO, \
|
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_INFO, \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \
|
||||||
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_WARNING, \
|
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_WARNING, \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \
|
||||||
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_ERROR, \
|
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_ERROR, \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \
|
||||||
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_FATAL, \
|
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_FATAL, \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \
|
#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \
|
||||||
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_DFATAL, \
|
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_DFATAL, \
|
||||||
##__VA_ARGS__)
|
##__VA_ARGS__)
|
||||||
|
|
||||||
#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage)
|
#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage)
|
||||||
#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage)
|
#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage)
|
||||||
@@ -553,12 +573,7 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
|
|||||||
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
|
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
|
||||||
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2)
|
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2)
|
||||||
|
|
||||||
#if defined(NDEBUG) && defined(OS_CHROMEOS)
|
|
||||||
#define NOTREACHED() \
|
|
||||||
LOG(ERROR) << "NOTREACHED() hit in " << __FUNCTION__ << ". "
|
|
||||||
#else
|
|
||||||
#define NOTREACHED() DCHECK(false)
|
#define NOTREACHED() DCHECK(false)
|
||||||
#endif
|
|
||||||
|
|
||||||
// Redefine the standard assert to use our nice log files
|
// Redefine the standard assert to use our nice log files
|
||||||
#undef assert
|
#undef assert
|
||||||
@@ -587,6 +602,9 @@ class LogMessage {
|
|||||||
LogSeverity severity,
|
LogSeverity severity,
|
||||||
std::string* result);
|
std::string* result);
|
||||||
|
|
||||||
|
LogMessage(const LogMessage&) = delete;
|
||||||
|
LogMessage& operator=(const LogMessage&) = delete;
|
||||||
|
|
||||||
~LogMessage();
|
~LogMessage();
|
||||||
|
|
||||||
std::ostream& stream() { return stream_; }
|
std::ostream& stream() { return stream_; }
|
||||||
@@ -618,8 +636,6 @@ class LogMessage {
|
|||||||
|
|
||||||
SaveLastError last_error_;
|
SaveLastError last_error_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(LogMessage);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A non-macro interface to the log facility; (useful
|
// A non-macro interface to the log facility; (useful
|
||||||
@@ -659,6 +675,9 @@ class Win32ErrorLogMessage {
|
|||||||
LogSeverity severity,
|
LogSeverity severity,
|
||||||
SystemErrorCode err);
|
SystemErrorCode err);
|
||||||
|
|
||||||
|
Win32ErrorLogMessage(const Win32ErrorLogMessage&) = delete;
|
||||||
|
Win32ErrorLogMessage& operator=(const Win32ErrorLogMessage&) = delete;
|
||||||
|
|
||||||
// Appends the error message before destructing the encapsulated class.
|
// Appends the error message before destructing the encapsulated class.
|
||||||
~Win32ErrorLogMessage();
|
~Win32ErrorLogMessage();
|
||||||
|
|
||||||
@@ -667,8 +686,6 @@ class Win32ErrorLogMessage {
|
|||||||
private:
|
private:
|
||||||
SystemErrorCode err_;
|
SystemErrorCode err_;
|
||||||
LogMessage log_message_;
|
LogMessage log_message_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage);
|
|
||||||
};
|
};
|
||||||
#elif defined(OS_POSIX)
|
#elif defined(OS_POSIX)
|
||||||
// Appends a formatted system message of the errno type
|
// Appends a formatted system message of the errno type
|
||||||
@@ -679,6 +696,9 @@ class ErrnoLogMessage {
|
|||||||
LogSeverity severity,
|
LogSeverity severity,
|
||||||
SystemErrorCode err);
|
SystemErrorCode err);
|
||||||
|
|
||||||
|
ErrnoLogMessage(const ErrnoLogMessage&) = delete;
|
||||||
|
ErrnoLogMessage& operator=(const ErrnoLogMessage&) = delete;
|
||||||
|
|
||||||
// Appends the error message before destructing the encapsulated class.
|
// Appends the error message before destructing the encapsulated class.
|
||||||
~ErrnoLogMessage();
|
~ErrnoLogMessage();
|
||||||
|
|
||||||
@@ -687,8 +707,6 @@ class ErrnoLogMessage {
|
|||||||
private:
|
private:
|
||||||
SystemErrorCode err_;
|
SystemErrorCode err_;
|
||||||
LogMessage log_message_;
|
LogMessage log_message_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ErrnoLogMessage);
|
|
||||||
};
|
};
|
||||||
#endif // OS_WIN
|
#endif // OS_WIN
|
||||||
|
|
||||||
@@ -705,6 +723,13 @@ std::ostream& operator<<(std::ostream& out, const wchar_t* wstr);
|
|||||||
inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
|
inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
|
||||||
return out << wstr.c_str();
|
return out << wstr.c_str();
|
||||||
}
|
}
|
||||||
|
#if defined(WCHAR_T_IS_32_BIT)
|
||||||
|
std::ostream& operator<<(std::ostream& out, const char16_t* wstr);
|
||||||
|
#elif defined(WCHAR_T_IS_16_BIT)
|
||||||
|
inline std::ostream& operator<<(std::ostream& out, const char16_t* wstr) {
|
||||||
|
return operator<<(out, reinterpret_cast<const wchar_t*>(wstr));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// The NOTIMPLEMENTED() macro annotates codepaths which have
|
// The NOTIMPLEMENTED() macro annotates codepaths which have
|
||||||
// not been implemented yet.
|
// not been implemented yet.
|
||||||
|
|||||||
@@ -32,189 +32,32 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_MACROS_H_
|
#define CEF_INCLUDE_BASE_CEF_MACROS_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(USING_CHROMIUM_INCLUDES)
|
#if !defined(USING_CHROMIUM_INCLUDES)
|
||||||
// When building CEF include the Chromium header directly.
|
|
||||||
#include "base/macros.h"
|
|
||||||
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <stddef.h> // For size_t.
|
// ALL DISALLOW_xxx MACROS ARE DEPRECATED; DO NOT USE IN NEW CODE.
|
||||||
#include "include/base/cef_build.h" // For COMPILER_MSVC
|
// Use explicit deletions instead. For more information see
|
||||||
|
// https://chromium.googlesource.com/chromium/src/+/lkgr/styleguide/c++/c++-dos-and-donts.md#explicitly-declare-class-copyability_movability
|
||||||
|
|
||||||
#if !defined(arraysize)
|
// DEPRECATED: See above. Makes a class uncopyable.
|
||||||
|
#define DISALLOW_COPY(TypeName) TypeName(const TypeName&) = delete
|
||||||
|
|
||||||
// The arraysize(arr) macro returns the # of elements in an array arr.
|
// DEPRECATED: See above. Makes a class unassignable.
|
||||||
// The expression is a compile-time constant, and therefore can be
|
#define DISALLOW_ASSIGN(TypeName) TypeName& operator=(const TypeName&) = delete
|
||||||
// used in defining new arrays, for example. If you use arraysize on
|
|
||||||
// a pointer by mistake, you will get a compile-time error.
|
|
||||||
//
|
|
||||||
// One caveat is that arraysize() doesn't accept any array of an
|
|
||||||
// anonymous type or a type defined inside a function. In these rare
|
|
||||||
// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is
|
|
||||||
// due to a limitation in C++'s template system. The limitation might
|
|
||||||
// eventually be removed, but it hasn't happened yet.
|
|
||||||
|
|
||||||
// This template function declaration is used in defining arraysize.
|
// DEPRECATED: See above. Makes a class uncopyable and unassignable.
|
||||||
// Note that the function doesn't need an implementation, as we only
|
|
||||||
// use its type.
|
|
||||||
template <typename T, size_t N>
|
|
||||||
char (&ArraySizeHelper(T (&array)[N]))[N];
|
|
||||||
|
|
||||||
// That gcc wants both of these prototypes seems mysterious. VC, for
|
|
||||||
// its part, can't decide which to use (another mystery). Matching of
|
|
||||||
// template overloads: the final frontier.
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
template <typename T, size_t N>
|
|
||||||
char (&ArraySizeHelper(const T (&array)[N]))[N];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
|
|
||||||
|
|
||||||
#endif // !arraysize
|
|
||||||
|
|
||||||
#if !defined(DISALLOW_COPY_AND_ASSIGN)
|
|
||||||
|
|
||||||
// A macro to disallow the copy constructor and operator= functions
|
|
||||||
// This should be used in the private: declarations for a class
|
|
||||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
TypeName(const TypeName&); \
|
DISALLOW_COPY(TypeName); \
|
||||||
void operator=(const TypeName&)
|
DISALLOW_ASSIGN(TypeName)
|
||||||
|
|
||||||
#endif // !DISALLOW_COPY_AND_ASSIGN
|
// DEPRECATED: See above. Disallow all implicit constructors, namely the
|
||||||
|
|
||||||
#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS)
|
|
||||||
|
|
||||||
// A macro to disallow all the implicit constructors, namely the
|
|
||||||
// default constructor, copy constructor and operator= functions.
|
// default constructor, copy constructor and operator= functions.
|
||||||
//
|
|
||||||
// This should be used in the private: declarations for a class
|
|
||||||
// that wants to prevent anyone from instantiating it. This is
|
|
||||||
// especially useful for classes containing only static methods.
|
|
||||||
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
||||||
TypeName(); \
|
TypeName() = delete; \
|
||||||
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
||||||
|
|
||||||
#endif // !DISALLOW_IMPLICIT_CONSTRUCTORS
|
|
||||||
|
|
||||||
#if !defined(COMPILE_ASSERT)
|
|
||||||
|
|
||||||
// The COMPILE_ASSERT macro can be used to verify that a compile time
|
|
||||||
// expression is true. For example, you could use it to verify the
|
|
||||||
// size of a static array:
|
|
||||||
//
|
|
||||||
// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES,
|
|
||||||
// content_type_names_incorrect_size);
|
|
||||||
//
|
|
||||||
// or to make sure a struct is smaller than a certain size:
|
|
||||||
//
|
|
||||||
// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);
|
|
||||||
//
|
|
||||||
// The second argument to the macro is the name of the variable. If
|
|
||||||
// the expression is false, most compilers will issue a warning/error
|
|
||||||
// containing the name of the variable.
|
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
|
|
||||||
// Under C++11, just use static_assert.
|
|
||||||
#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
namespace cef {
|
|
||||||
|
|
||||||
template <bool>
|
|
||||||
struct CompileAssert {};
|
|
||||||
|
|
||||||
} // namespace cef
|
|
||||||
|
|
||||||
#define COMPILE_ASSERT(expr, msg) \
|
|
||||||
typedef cef::CompileAssert<(bool(expr))> \
|
|
||||||
msg[bool(expr) ? 1 : -1] ALLOW_UNUSED_TYPE
|
|
||||||
|
|
||||||
// Implementation details of COMPILE_ASSERT:
|
|
||||||
//
|
|
||||||
// - COMPILE_ASSERT works by defining an array type that has -1
|
|
||||||
// elements (and thus is invalid) when the expression is false.
|
|
||||||
//
|
|
||||||
// - The simpler definition
|
|
||||||
//
|
|
||||||
// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
|
|
||||||
//
|
|
||||||
// does not work, as gcc supports variable-length arrays whose sizes
|
|
||||||
// are determined at run-time (this is gcc's extension and not part
|
|
||||||
// of the C++ standard). As a result, gcc fails to reject the
|
|
||||||
// following code with the simple definition:
|
|
||||||
//
|
|
||||||
// int foo;
|
|
||||||
// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
|
|
||||||
// // not a compile-time constant.
|
|
||||||
//
|
|
||||||
// - By using the type CompileAssert<(bool(expr))>, we ensures that
|
|
||||||
// expr is a compile-time constant. (Template arguments must be
|
|
||||||
// determined at compile-time.)
|
|
||||||
//
|
|
||||||
// - The outer parentheses in CompileAssert<(bool(expr))> are necessary
|
|
||||||
// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
|
|
||||||
//
|
|
||||||
// CompileAssert<bool(expr)>
|
|
||||||
//
|
|
||||||
// instead, these compilers will refuse to compile
|
|
||||||
//
|
|
||||||
// COMPILE_ASSERT(5 > 0, some_message);
|
|
||||||
//
|
|
||||||
// (They seem to think the ">" in "5 > 0" marks the end of the
|
|
||||||
// template argument list.)
|
|
||||||
//
|
|
||||||
// - The array size is (bool(expr) ? 1 : -1), instead of simply
|
|
||||||
//
|
|
||||||
// ((expr) ? 1 : -1).
|
|
||||||
//
|
|
||||||
// This is to avoid running into a bug in MS VC 7.1, which
|
|
||||||
// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
|
|
||||||
|
|
||||||
#endif // !(__cplusplus >= 201103L)
|
|
||||||
|
|
||||||
#endif // !defined(COMPILE_ASSERT)
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
#if !defined(MSVC_PUSH_DISABLE_WARNING) && defined(COMPILER_MSVC)
|
|
||||||
|
|
||||||
// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled.
|
|
||||||
// The warning remains disabled until popped by MSVC_POP_WARNING.
|
|
||||||
#define MSVC_PUSH_DISABLE_WARNING(n) \
|
|
||||||
__pragma(warning(push)) __pragma(warning(disable : n))
|
|
||||||
|
|
||||||
// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level
|
|
||||||
// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all
|
|
||||||
// warnings.
|
|
||||||
#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n))
|
|
||||||
|
|
||||||
// Pop effects of innermost MSVC_PUSH_* macro.
|
|
||||||
#define MSVC_POP_WARNING() __pragma(warning(pop))
|
|
||||||
|
|
||||||
#endif // !defined(MSVC_PUSH_DISABLE_WARNING) && defined(COMPILER_MSVC)
|
|
||||||
|
|
||||||
#if !defined(ALLOW_THIS_IN_INITIALIZER_LIST)
|
|
||||||
#if defined(COMPILER_MSVC)
|
|
||||||
// Allows |this| to be passed as an argument in constructor initializer lists.
|
|
||||||
// This uses push/pop instead of the seemingly simpler suppress feature to avoid
|
|
||||||
// having the warning be disabled for more than just |code|.
|
|
||||||
//
|
|
||||||
// Example usage:
|
|
||||||
// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {}
|
|
||||||
//
|
|
||||||
// Compiler warning C4355: 'this': used in base member initializer list:
|
|
||||||
// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx
|
|
||||||
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) \
|
|
||||||
MSVC_PUSH_DISABLE_WARNING(4355) \
|
|
||||||
code MSVC_POP_WARNING()
|
|
||||||
#else // !COMPILER_MSVC
|
|
||||||
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code
|
|
||||||
#endif // !COMPILER_MSVC
|
|
||||||
#endif // !ALLOW_THIS_IN_INITIALIZER_LIST
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_
|
#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_
|
||||||
|
|||||||
@@ -1,261 +0,0 @@
|
|||||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
|
||||||
// Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_MOVE_H_
|
|
||||||
#define CEF_INCLUDE_BASE_CEF_MOVE_H_
|
|
||||||
|
|
||||||
#if defined(MOVE_ONLY_TYPE_FOR_CPP_03)
|
|
||||||
// Do nothing if the macro in this header has already been defined.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
|
||||||
#include "base/move.h"
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
|
||||||
// The following is substantially similar to the Chromium implementation.
|
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
|
||||||
// updated to match.
|
|
||||||
|
|
||||||
// Macro with the boilerplate that makes a type move-only in C++03.
|
|
||||||
//
|
|
||||||
// USAGE
|
|
||||||
//
|
|
||||||
// This macro should be used instead of DISALLOW_COPY_AND_ASSIGN to create
|
|
||||||
// a "move-only" type. Unlike DISALLOW_COPY_AND_ASSIGN, this macro should be
|
|
||||||
// the first line in a class declaration.
|
|
||||||
//
|
|
||||||
// A class using this macro must call .Pass() (or somehow be an r-value already)
|
|
||||||
// before it can be:
|
|
||||||
//
|
|
||||||
// * Passed as a function argument
|
|
||||||
// * Used as the right-hand side of an assignment
|
|
||||||
// * Returned from a function
|
|
||||||
//
|
|
||||||
// Each class will still need to define their own "move constructor" and "move
|
|
||||||
// operator=" to make this useful. Here's an example of the macro, the move
|
|
||||||
// constructor, and the move operator= from the scoped_ptr class:
|
|
||||||
//
|
|
||||||
// template <typename T>
|
|
||||||
// class scoped_ptr {
|
|
||||||
// MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
|
|
||||||
// public:
|
|
||||||
// scoped_ptr(RValue& other) : ptr_(other.release()) { }
|
|
||||||
// scoped_ptr& operator=(RValue& other) {
|
|
||||||
// swap(other);
|
|
||||||
// return *this;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// Note that the constructor must NOT be marked explicit.
|
|
||||||
//
|
|
||||||
// For consistency, the second parameter to the macro should always be RValue
|
|
||||||
// unless you have a strong reason to do otherwise. It is only exposed as a
|
|
||||||
// macro parameter so that the move constructor and move operator= don't look
|
|
||||||
// like they're using a phantom type.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// HOW THIS WORKS
|
|
||||||
//
|
|
||||||
// For a thorough explanation of this technique, see:
|
|
||||||
//
|
|
||||||
// http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Move_Constructor
|
|
||||||
//
|
|
||||||
// The summary is that we take advantage of 2 properties:
|
|
||||||
//
|
|
||||||
// 1) non-const references will not bind to r-values.
|
|
||||||
// 2) C++ can apply one user-defined conversion when initializing a
|
|
||||||
// variable.
|
|
||||||
//
|
|
||||||
// The first lets us disable the copy constructor and assignment operator
|
|
||||||
// by declaring private version of them with a non-const reference parameter.
|
|
||||||
//
|
|
||||||
// For l-values, direct initialization still fails like in
|
|
||||||
// DISALLOW_COPY_AND_ASSIGN because the copy constructor and assignment
|
|
||||||
// operators are private.
|
|
||||||
//
|
|
||||||
// For r-values, the situation is different. The copy constructor and
|
|
||||||
// assignment operator are not viable due to (1), so we are trying to call
|
|
||||||
// a non-existent constructor and non-existing operator= rather than a private
|
|
||||||
// one. Since we have not committed an error quite yet, we can provide an
|
|
||||||
// alternate conversion sequence and a constructor. We add
|
|
||||||
//
|
|
||||||
// * a private struct named "RValue"
|
|
||||||
// * a user-defined conversion "operator RValue()"
|
|
||||||
// * a "move constructor" and "move operator=" that take the RValue& as
|
|
||||||
// their sole parameter.
|
|
||||||
//
|
|
||||||
// Only r-values will trigger this sequence and execute our "move constructor"
|
|
||||||
// or "move operator=." L-values will match the private copy constructor and
|
|
||||||
// operator= first giving a "private in this context" error. This combination
|
|
||||||
// gives us a move-only type.
|
|
||||||
//
|
|
||||||
// For signaling a destructive transfer of data from an l-value, we provide a
|
|
||||||
// method named Pass() which creates an r-value for the current instance
|
|
||||||
// triggering the move constructor or move operator=.
|
|
||||||
//
|
|
||||||
// Other ways to get r-values is to use the result of an expression like a
|
|
||||||
// function call.
|
|
||||||
//
|
|
||||||
// Here's an example with comments explaining what gets triggered where:
|
|
||||||
//
|
|
||||||
// class Foo {
|
|
||||||
// MOVE_ONLY_TYPE_FOR_CPP_03(Foo, RValue);
|
|
||||||
//
|
|
||||||
// public:
|
|
||||||
// ... API ...
|
|
||||||
// Foo(RValue other); // Move constructor.
|
|
||||||
// Foo& operator=(RValue rhs); // Move operator=
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// Foo MakeFoo(); // Function that returns a Foo.
|
|
||||||
//
|
|
||||||
// Foo f;
|
|
||||||
// Foo f_copy(f); // ERROR: Foo(Foo&) is private in this context.
|
|
||||||
// Foo f_assign;
|
|
||||||
// f_assign = f; // ERROR: operator=(Foo&) is private in this context.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Foo f(MakeFoo()); // R-value so alternate conversion executed.
|
|
||||||
// Foo f_copy(f.Pass()); // R-value so alternate conversion executed.
|
|
||||||
// f = f_copy.Pass(); // R-value so alternate conversion executed.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// IMPLEMENTATION SUBTLETIES WITH RValue
|
|
||||||
//
|
|
||||||
// The RValue struct is just a container for a pointer back to the original
|
|
||||||
// object. It should only ever be created as a temporary, and no external
|
|
||||||
// class should ever declare it or use it in a parameter.
|
|
||||||
//
|
|
||||||
// It is tempting to want to use the RValue type in function parameters, but
|
|
||||||
// excluding the limited usage here for the move constructor and move
|
|
||||||
// operator=, doing so would mean that the function could take both r-values
|
|
||||||
// and l-values equially which is unexpected. See COMPARED To Boost.Move for
|
|
||||||
// more details.
|
|
||||||
//
|
|
||||||
// An alternate, and incorrect, implementation of the RValue class used by
|
|
||||||
// Boost.Move makes RValue a fieldless child of the move-only type. RValue&
|
|
||||||
// is then used in place of RValue in the various operators. The RValue& is
|
|
||||||
// "created" by doing *reinterpret_cast<RValue*>(this). This has the appeal
|
|
||||||
// of never creating a temporary RValue struct even with optimizations
|
|
||||||
// disabled. Also, by virtue of inheritance you can treat the RValue
|
|
||||||
// reference as if it were the move-only type itself. Unfortunately,
|
|
||||||
// using the result of this reinterpret_cast<> is actually undefined behavior
|
|
||||||
// due to C++98 5.2.10.7. In certain compilers (e.g., NaCl) the optimizer
|
|
||||||
// will generate non-working code.
|
|
||||||
//
|
|
||||||
// In optimized builds, both implementations generate the same assembly so we
|
|
||||||
// choose the one that adheres to the standard.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// WHY HAVE typedef void MoveOnlyTypeForCPP03
|
|
||||||
//
|
|
||||||
// Callback<>/Bind() needs to understand movable-but-not-copyable semantics
|
|
||||||
// to call .Pass() appropriately when it is expected to transfer the value.
|
|
||||||
// The cryptic typedef MoveOnlyTypeForCPP03 is added to make this check
|
|
||||||
// easy and automatic in helper templates for Callback<>/Bind().
|
|
||||||
// See IsMoveOnlyType template and its usage in base/callback_internal.h
|
|
||||||
// for more details.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// COMPARED TO C++11
|
|
||||||
//
|
|
||||||
// In C++11, you would implement this functionality using an r-value reference
|
|
||||||
// and our .Pass() method would be replaced with a call to std::move().
|
|
||||||
//
|
|
||||||
// This emulation also has a deficiency where it uses up the single
|
|
||||||
// user-defined conversion allowed by C++ during initialization. This can
|
|
||||||
// cause problems in some API edge cases. For instance, in scoped_ptr, it is
|
|
||||||
// impossible to make a function "void Foo(scoped_ptr<Parent> p)" accept a
|
|
||||||
// value of type scoped_ptr<Child> even if you add a constructor to
|
|
||||||
// scoped_ptr<> that would make it look like it should work. C++11 does not
|
|
||||||
// have this deficiency.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// COMPARED TO Boost.Move
|
|
||||||
//
|
|
||||||
// Our implementation similar to Boost.Move, but we keep the RValue struct
|
|
||||||
// private to the move-only type, and we don't use the reinterpret_cast<> hack.
|
|
||||||
//
|
|
||||||
// In Boost.Move, RValue is the boost::rv<> template. This type can be used
|
|
||||||
// when writing APIs like:
|
|
||||||
//
|
|
||||||
// void MyFunc(boost::rv<Foo>& f)
|
|
||||||
//
|
|
||||||
// that can take advantage of rv<> to avoid extra copies of a type. However you
|
|
||||||
// would still be able to call this version of MyFunc with an l-value:
|
|
||||||
//
|
|
||||||
// Foo f;
|
|
||||||
// MyFunc(f); // Uh oh, we probably just destroyed |f| w/o calling Pass().
|
|
||||||
//
|
|
||||||
// unless someone is very careful to also declare a parallel override like:
|
|
||||||
//
|
|
||||||
// void MyFunc(const Foo& f)
|
|
||||||
//
|
|
||||||
// that would catch the l-values first. This was declared unsafe in C++11 and
|
|
||||||
// a C++11 compiler will explicitly fail MyFunc(f). Unfortunately, we cannot
|
|
||||||
// ensure this in C++03.
|
|
||||||
//
|
|
||||||
// Since we have no need for writing such APIs yet, our implementation keeps
|
|
||||||
// RValue private and uses a .Pass() method to do the conversion instead of
|
|
||||||
// trying to write a version of "std::move()." Writing an API like std::move()
|
|
||||||
// would require the RValue struct to be public.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// CAVEATS
|
|
||||||
//
|
|
||||||
// If you include a move-only type as a field inside a class that does not
|
|
||||||
// explicitly declare a copy constructor, the containing class's implicit
|
|
||||||
// copy constructor will change from Containing(const Containing&) to
|
|
||||||
// Containing(Containing&). This can cause some unexpected errors.
|
|
||||||
//
|
|
||||||
// http://llvm.org/bugs/show_bug.cgi?id=11528
|
|
||||||
//
|
|
||||||
// The workaround is to explicitly declare your copy constructor.
|
|
||||||
//
|
|
||||||
#define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \
|
|
||||||
private: \
|
|
||||||
struct rvalue_type { \
|
|
||||||
explicit rvalue_type(type* object) : object(object) {} \
|
|
||||||
type* object; \
|
|
||||||
}; \
|
|
||||||
type(type&); \
|
|
||||||
void operator=(type&); \
|
|
||||||
\
|
|
||||||
public: \
|
|
||||||
operator rvalue_type() { return rvalue_type(this); } \
|
|
||||||
type Pass() { return type(rvalue_type(this)); } \
|
|
||||||
typedef void MoveOnlyTypeForCPP03; \
|
|
||||||
\
|
|
||||||
private:
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_MOVE_H_
|
|
||||||
@@ -35,12 +35,7 @@
|
|||||||
#ifndef CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
#ifndef CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
||||||
#define CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
#define CEF_INCLUDE_BASE_PLATFORM_THREAD_H_
|
||||||
|
|
||||||
#if defined(BASE_THREADING_PLATFORM_THREAD_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/threading/platform_thread.h"
|
#include "base/threading/platform_thread.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -48,23 +43,26 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include "include/base/cef_basictypes.h"
|
|
||||||
#include "include/base/cef_build.h"
|
#include "include/base/cef_build.h"
|
||||||
#include "include/internal/cef_thread_internal.h"
|
#include "include/internal/cef_thread_internal.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
// Used for logging. Always an integer value.
|
///
|
||||||
|
/// Used for logging. Always an integer value.
|
||||||
|
///
|
||||||
typedef cef_platform_thread_id_t PlatformThreadId;
|
typedef cef_platform_thread_id_t PlatformThreadId;
|
||||||
|
|
||||||
// Used for thread checking and debugging.
|
///
|
||||||
// Meant to be as fast as possible.
|
/// Used for thread checking and debugging.
|
||||||
// These are produced by PlatformThread::CurrentRef(), and used to later
|
/// Meant to be as fast as possible.
|
||||||
// check if we are on the same thread or not by using ==. These are safe
|
/// These are produced by PlatformThread::CurrentRef(), and used to later
|
||||||
// to copy between threads, but can't be copied to another process as they
|
/// check if we are on the same thread or not by using ==. These are safe
|
||||||
// have no meaning there. Also, the internal identifier can be re-used
|
/// to copy between threads, but can't be copied to another process as they
|
||||||
// after a thread dies, so a PlatformThreadRef cannot be reliably used
|
/// have no meaning there. Also, the internal identifier can be re-used
|
||||||
// to distinguish a new thread from an old, dead thread.
|
/// after a thread dies, so a PlatformThreadRef cannot be reliably used
|
||||||
|
/// to distinguish a new thread from an old, dead thread.
|
||||||
|
///
|
||||||
class PlatformThreadRef {
|
class PlatformThreadRef {
|
||||||
public:
|
public:
|
||||||
typedef cef_platform_thread_handle_t RefType;
|
typedef cef_platform_thread_handle_t RefType;
|
||||||
@@ -81,18 +79,24 @@ class PlatformThreadRef {
|
|||||||
RefType id_;
|
RefType id_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// A namespace for low-level thread functions.
|
///
|
||||||
// Chromium uses a class with static methods but CEF uses an actual namespace
|
/// A namespace for low-level thread functions.
|
||||||
// to avoid linker problems with the sandbox libaries on Windows.
|
/// Chromium uses a class with static methods but CEF uses an actual namespace
|
||||||
|
/// to avoid linker problems with the sandbox libaries on Windows.
|
||||||
|
///
|
||||||
namespace PlatformThread {
|
namespace PlatformThread {
|
||||||
|
|
||||||
// Gets the current thread id, which may be useful for logging purposes.
|
///
|
||||||
|
/// Gets the current thread id, which may be useful for logging purposes.
|
||||||
|
///
|
||||||
inline PlatformThreadId CurrentId() {
|
inline PlatformThreadId CurrentId() {
|
||||||
return cef_get_current_platform_thread_id();
|
return cef_get_current_platform_thread_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the current thread reference, which can be used to check if
|
///
|
||||||
// we're on the right thread quickly.
|
/// Gets the current thread reference, which can be used to check if
|
||||||
|
/// we're on the right thread quickly.
|
||||||
|
///
|
||||||
inline PlatformThreadRef CurrentRef() {
|
inline PlatformThreadRef CurrentRef() {
|
||||||
return PlatformThreadRef(cef_get_current_platform_thread_handle());
|
return PlatformThreadRef(cef_get_current_platform_thread_handle());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,7 @@
|
|||||||
#define CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
#define CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_MEMORY_REF_COUNTED_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -46,15 +41,18 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include <cassert>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "include/base/cef_atomic_ref_count.h"
|
#include "include/base/cef_atomic_ref_count.h"
|
||||||
#include "include/base/cef_build.h"
|
#include "include/base/cef_build.h"
|
||||||
|
#include "include/base/cef_compiler_specific.h"
|
||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/cef_macros.h"
|
#include "include/base/cef_scoped_refptr.h"
|
||||||
|
#include "include/base/cef_thread_checker.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
namespace cef_subtle {
|
namespace cef_subtle {
|
||||||
|
|
||||||
class RefCountedBase {
|
class RefCountedBase {
|
||||||
@@ -63,15 +61,22 @@ class RefCountedBase {
|
|||||||
bool HasAtLeastOneRef() const { return ref_count_ >= 1; }
|
bool HasAtLeastOneRef() const { return ref_count_ >= 1; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RefCountedBase()
|
explicit RefCountedBase(StartRefCountFromZeroTag) {
|
||||||
: ref_count_(0)
|
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
,
|
thread_checker_.DetachFromThread();
|
||||||
in_dtor_(false)
|
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explicit RefCountedBase(StartRefCountFromOneTag) : ref_count_(1) {
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
needs_adopt_ref_ = true;
|
||||||
|
thread_checker_.DetachFromThread();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
RefCountedBase(const RefCountedBase&) = delete;
|
||||||
|
RefCountedBase& operator=(const RefCountedBase&) = delete;
|
||||||
|
|
||||||
~RefCountedBase() {
|
~RefCountedBase() {
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
|
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
|
||||||
@@ -81,31 +86,92 @@ class RefCountedBase {
|
|||||||
void AddRef() const {
|
void AddRef() const {
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
DCHECK(!in_dtor_);
|
DCHECK(!in_dtor_);
|
||||||
|
DCHECK(!needs_adopt_ref_)
|
||||||
|
<< "This RefCounted object is created with non-zero reference count."
|
||||||
|
<< " The first reference to such a object has to be made by AdoptRef or"
|
||||||
|
<< " MakeRefCounted.";
|
||||||
|
if (ref_count_ >= 1) {
|
||||||
|
DCHECK(CalledOnValidThread());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
++ref_count_;
|
|
||||||
|
AddRefImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the object should self-delete.
|
// Returns true if the object should self-delete.
|
||||||
bool Release() const {
|
bool Release() const {
|
||||||
|
ReleaseImpl();
|
||||||
|
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
DCHECK(!in_dtor_);
|
DCHECK(!in_dtor_);
|
||||||
#endif
|
if (ref_count_ == 0) {
|
||||||
if (--ref_count_ == 0) {
|
|
||||||
#if DCHECK_IS_ON()
|
|
||||||
in_dtor_ = true;
|
in_dtor_ = true;
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
if (ref_count_ >= 1) {
|
||||||
|
DCHECK(CalledOnValidThread());
|
||||||
|
}
|
||||||
|
if (ref_count_ == 1) {
|
||||||
|
thread_checker_.DetachFromThread();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ref_count_ == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if it is safe to read or write the object, from a thread
|
||||||
|
// safety standpoint. Should be DCHECK'd from the methods of RefCounted
|
||||||
|
// classes if there is a danger of objects being shared across threads.
|
||||||
|
//
|
||||||
|
// This produces fewer false positives than adding a separate ThreadChecker
|
||||||
|
// into the subclass, because it automatically detaches from the thread when
|
||||||
|
// the reference count is 1 (and never fails if there is only one reference).
|
||||||
|
//
|
||||||
|
// This means unlike a separate ThreadChecker, it will permit a singly
|
||||||
|
// referenced object to be passed between threads (not holding a reference on
|
||||||
|
// the sending thread), but will trap if the sending thread holds onto a
|
||||||
|
// reference, or if the object is accessed from multiple threads
|
||||||
|
// simultaneously.
|
||||||
|
bool IsOnValidThread() const {
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
return ref_count_ <= 1 || CalledOnValidThread();
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable int ref_count_;
|
template <typename U>
|
||||||
|
friend scoped_refptr<U> base::AdoptRef(U*);
|
||||||
|
|
||||||
|
void Adopted() const {
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
mutable bool in_dtor_;
|
DCHECK(needs_adopt_ref_);
|
||||||
|
needs_adopt_ref_ = false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(ARCH_CPU_64_BITS)
|
||||||
|
void AddRefImpl() const;
|
||||||
|
void ReleaseImpl() const;
|
||||||
|
#else
|
||||||
|
void AddRefImpl() const { ++ref_count_; }
|
||||||
|
void ReleaseImpl() const { --ref_count_; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
|
#if DCHECK_IS_ON()
|
||||||
|
bool CalledOnValidThread() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mutable uint32_t ref_count_ = 0;
|
||||||
|
static_assert(std::is_unsigned<decltype(ref_count_)>::value,
|
||||||
|
"ref_count_ must be an unsigned type.");
|
||||||
|
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
mutable bool needs_adopt_ref_ = false;
|
||||||
|
mutable bool in_dtor_ = false;
|
||||||
|
mutable ThreadChecker thread_checker_;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
class RefCountedThreadSafeBase {
|
class RefCountedThreadSafeBase {
|
||||||
@@ -114,65 +180,227 @@ class RefCountedThreadSafeBase {
|
|||||||
bool HasAtLeastOneRef() const;
|
bool HasAtLeastOneRef() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RefCountedThreadSafeBase();
|
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromZeroTag) {}
|
||||||
~RefCountedThreadSafeBase();
|
explicit constexpr RefCountedThreadSafeBase(StartRefCountFromOneTag)
|
||||||
|
: ref_count_(1) {
|
||||||
void AddRef() const;
|
|
||||||
|
|
||||||
// Returns true if the object should self-delete.
|
|
||||||
bool Release() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
mutable AtomicRefCount ref_count_;
|
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
mutable bool in_dtor_;
|
needs_adopt_ref_ = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
RefCountedThreadSafeBase(const RefCountedThreadSafeBase&) = delete;
|
||||||
|
RefCountedThreadSafeBase& operator=(const RefCountedThreadSafeBase&) = delete;
|
||||||
|
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
~RefCountedThreadSafeBase();
|
||||||
|
#else
|
||||||
|
~RefCountedThreadSafeBase() = default;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
|
// Release and AddRef are suitable for inlining on X86 because they generate
|
||||||
|
// very small code threads. On other platforms (ARM), it causes a size
|
||||||
|
// regression and is probably not worth it.
|
||||||
|
#if defined(ARCH_CPU_X86_FAMILY)
|
||||||
|
// Returns true if the object should self-delete.
|
||||||
|
bool Release() const { return ReleaseImpl(); }
|
||||||
|
void AddRef() const { AddRefImpl(); }
|
||||||
|
void AddRefWithCheck() const { AddRefWithCheckImpl(); }
|
||||||
|
#else
|
||||||
|
// Returns true if the object should self-delete.
|
||||||
|
bool Release() const;
|
||||||
|
void AddRef() const;
|
||||||
|
void AddRefWithCheck() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename U>
|
||||||
|
friend scoped_refptr<U> base::AdoptRef(U*);
|
||||||
|
|
||||||
|
void Adopted() const {
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
DCHECK(needs_adopt_ref_);
|
||||||
|
needs_adopt_ref_ = false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE void AddRefImpl() const {
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
DCHECK(!in_dtor_);
|
||||||
|
DCHECK(!needs_adopt_ref_)
|
||||||
|
<< "This RefCounted object is created with non-zero reference count."
|
||||||
|
<< " The first reference to such a object has to be made by AdoptRef or"
|
||||||
|
<< " MakeRefCounted.";
|
||||||
|
#endif
|
||||||
|
ref_count_.Increment();
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE void AddRefWithCheckImpl() const {
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
DCHECK(!in_dtor_);
|
||||||
|
DCHECK(!needs_adopt_ref_)
|
||||||
|
<< "This RefCounted object is created with non-zero reference count."
|
||||||
|
<< " The first reference to such a object has to be made by AdoptRef or"
|
||||||
|
<< " MakeRefCounted.";
|
||||||
|
#endif
|
||||||
|
CHECK(ref_count_.Increment() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE bool ReleaseImpl() const {
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
DCHECK(!in_dtor_);
|
||||||
|
DCHECK(!ref_count_.IsZero());
|
||||||
|
#endif
|
||||||
|
if (!ref_count_.Decrement()) {
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
in_dtor_ = true;
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutable AtomicRefCount ref_count_{0};
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
mutable bool needs_adopt_ref_ = false;
|
||||||
|
mutable bool in_dtor_ = false;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
// ScopedAllowCrossThreadRefCountAccess disables the check documented on
|
||||||
|
// RefCounted below for rare pre-existing use cases where thread-safety was
|
||||||
|
// guaranteed through other means (e.g. explicit sequencing of calls across
|
||||||
|
// execution threads when bouncing between threads in order). New callers
|
||||||
|
// should refrain from using this (callsites handling thread-safety through
|
||||||
|
// locks should use RefCountedThreadSafe per the overhead of its atomics being
|
||||||
|
// negligible compared to locks anyways and callsites doing explicit sequencing
|
||||||
|
// should properly std::move() the ref to avoid hitting this check).
|
||||||
|
// TODO(tzik): Cleanup existing use cases and remove
|
||||||
|
// ScopedAllowCrossThreadRefCountAccess.
|
||||||
|
class ScopedAllowCrossThreadRefCountAccess final {
|
||||||
|
public:
|
||||||
|
#if DCHECK_IS_ON()
|
||||||
|
ScopedAllowCrossThreadRefCountAccess();
|
||||||
|
~ScopedAllowCrossThreadRefCountAccess();
|
||||||
|
#else
|
||||||
|
ScopedAllowCrossThreadRefCountAccess() {}
|
||||||
|
~ScopedAllowCrossThreadRefCountAccess() {}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cef_subtle
|
} // namespace cef_subtle
|
||||||
|
|
||||||
//
|
using ScopedAllowCrossThreadRefCountAccess =
|
||||||
// A base class for reference counted classes. Otherwise, known as a cheap
|
cef_subtle::ScopedAllowCrossThreadRefCountAccess;
|
||||||
// knock-off of WebKit's RefCounted<T> class. To use this guy just extend your
|
|
||||||
// class from it like so:
|
///
|
||||||
//
|
/// The reference count starts from zero by default, and we intended to migrate
|
||||||
// class MyFoo : public base::RefCounted<MyFoo> {
|
/// to start-from-one ref count. Put REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() to
|
||||||
// ...
|
/// the ref counted class to opt-in.
|
||||||
// private:
|
///
|
||||||
// friend class base::RefCounted<MyFoo>;
|
/// If an object has start-from-one ref count, the first scoped_refptr need to
|
||||||
// ~MyFoo();
|
/// be created by base::AdoptRef() or base::MakeRefCounted(). We can use
|
||||||
// };
|
/// base::MakeRefCounted() to create create both type of ref counted object.
|
||||||
//
|
///
|
||||||
// You should always make your destructor private, to avoid any code deleting
|
/// The motivations to use start-from-one ref count are:
|
||||||
// the object accidently while there are references to it.
|
/// - Start-from-one ref count doesn't need the ref count increment for the
|
||||||
template <class T>
|
/// first reference.
|
||||||
|
/// - It can detect an invalid object acquisition for a being-deleted object
|
||||||
|
/// that has zero ref count. That tends to happen on custom deleter that
|
||||||
|
/// delays the deletion.
|
||||||
|
/// TODO(tzik): Implement invalid acquisition detection.
|
||||||
|
/// - Behavior parity to Blink's WTF::RefCounted, whose count starts from one.
|
||||||
|
/// And start-from-one ref count is a step to merge WTF::RefCounted into
|
||||||
|
/// base::RefCounted.
|
||||||
|
///
|
||||||
|
#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() \
|
||||||
|
static constexpr ::base::cef_subtle::StartRefCountFromOneTag \
|
||||||
|
kRefCountPreference = ::base::cef_subtle::kStartRefCountFromOneTag
|
||||||
|
|
||||||
|
template <class T, typename Traits>
|
||||||
|
class RefCounted;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Default traits for RefCounted<T>. Deletes the object when its ref count
|
||||||
|
/// reaches 0. Overload to delete it on a different thread etc.
|
||||||
|
///
|
||||||
|
template <typename T>
|
||||||
|
struct DefaultRefCountedTraits {
|
||||||
|
static void Destruct(const T* x) {
|
||||||
|
RefCounted<T, DefaultRefCountedTraits>::DeleteInternal(x);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A base class for reference counted classes. Otherwise, known as a cheap
|
||||||
|
/// knock-off of WebKit's RefCounted<T> class. To use this, just extend your
|
||||||
|
/// class from it like so:
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// class MyFoo : public base::RefCounted<MyFoo> {
|
||||||
|
/// ...
|
||||||
|
/// private:
|
||||||
|
/// friend class base::RefCounted<MyFoo>;
|
||||||
|
/// ~MyFoo();
|
||||||
|
/// };
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// Usage Notes:
|
||||||
|
/// 1. You should always make your destructor non-public, to avoid any code
|
||||||
|
/// deleting the object accidentally while there are references to it.
|
||||||
|
/// 2. You should always make the ref-counted base class a friend of your class,
|
||||||
|
/// so that it can access the destructor.
|
||||||
|
///
|
||||||
|
/// The ref count manipulation to RefCounted is NOT thread safe and has DCHECKs
|
||||||
|
/// to trap unsafe cross thread usage. A subclass instance of RefCounted can be
|
||||||
|
/// passed to another execution thread only when its ref count is 1. If the ref
|
||||||
|
/// count is more than 1, the RefCounted class verifies the ref updates are made
|
||||||
|
/// on the same execution thread as the previous ones. The subclass can also
|
||||||
|
/// manually call IsOnValidThread to trap other non-thread-safe accesses; see
|
||||||
|
/// the documentation for that method.
|
||||||
|
///
|
||||||
|
template <class T, typename Traits = DefaultRefCountedTraits<T>>
|
||||||
class RefCounted : public cef_subtle::RefCountedBase {
|
class RefCounted : public cef_subtle::RefCountedBase {
|
||||||
public:
|
public:
|
||||||
RefCounted() {}
|
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
||||||
|
cef_subtle::kStartRefCountFromZeroTag;
|
||||||
|
|
||||||
|
RefCounted() : cef_subtle::RefCountedBase(T::kRefCountPreference) {}
|
||||||
|
|
||||||
|
RefCounted(const RefCounted&) = delete;
|
||||||
|
RefCounted& operator=(const RefCounted&) = delete;
|
||||||
|
|
||||||
void AddRef() const { cef_subtle::RefCountedBase::AddRef(); }
|
void AddRef() const { cef_subtle::RefCountedBase::AddRef(); }
|
||||||
|
|
||||||
void Release() const {
|
void Release() const {
|
||||||
if (cef_subtle::RefCountedBase::Release()) {
|
if (cef_subtle::RefCountedBase::Release()) {
|
||||||
delete static_cast<const T*>(this);
|
// Prune the code paths which the static analyzer may take to simulate
|
||||||
|
// object destruction. Use-after-free errors aren't possible given the
|
||||||
|
// lifetime guarantees of the refcounting system.
|
||||||
|
ANALYZER_SKIP_THIS_PATH();
|
||||||
|
|
||||||
|
Traits::Destruct(static_cast<const T*>(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~RefCounted() {}
|
~RefCounted() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCounted<T>);
|
friend struct DefaultRefCountedTraits<T>;
|
||||||
|
template <typename U>
|
||||||
|
static void DeleteInternal(const U* x) {
|
||||||
|
delete x;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Forward declaration.
|
// Forward declaration.
|
||||||
template <class T, typename Traits>
|
template <class T, typename Traits>
|
||||||
class RefCountedThreadSafe;
|
class RefCountedThreadSafe;
|
||||||
|
|
||||||
// Default traits for RefCountedThreadSafe<T>. Deletes the object when its ref
|
///
|
||||||
// count reaches 0. Overload to delete it on a different thread etc.
|
/// Default traits for RefCountedThreadSafe<T>. Deletes the object when its ref
|
||||||
|
/// count reaches 0. Overload to delete it on a different thread etc.
|
||||||
|
///
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct DefaultRefCountedThreadSafeTraits {
|
struct DefaultRefCountedThreadSafeTraits {
|
||||||
static void Destruct(const T* x) {
|
static void Destruct(const T* x) {
|
||||||
@@ -184,187 +412,100 @@ struct DefaultRefCountedThreadSafeTraits {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
///
|
||||||
// A thread-safe variant of RefCounted<T>
|
/// A thread-safe variant of RefCounted<T>
|
||||||
//
|
///
|
||||||
// class MyFoo : public base::RefCountedThreadSafe<MyFoo> {
|
/// <pre>
|
||||||
// ...
|
/// class MyFoo : public base::RefCountedThreadSafe<MyFoo> {
|
||||||
// };
|
/// ...
|
||||||
//
|
/// };
|
||||||
// If you're using the default trait, then you should add compile time
|
/// </pre>
|
||||||
// asserts that no one else is deleting your object. i.e.
|
///
|
||||||
// private:
|
/// If you're using the default trait, then you should add compile time
|
||||||
// friend class base::RefCountedThreadSafe<MyFoo>;
|
/// asserts that no one else is deleting your object. i.e.
|
||||||
// ~MyFoo();
|
/// <pre>
|
||||||
|
/// private:
|
||||||
|
/// friend class base::RefCountedThreadSafe<MyFoo>;
|
||||||
|
/// ~MyFoo();
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// We can use REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() with RefCountedThreadSafe
|
||||||
|
/// too. See the comment above the RefCounted definition for details.
|
||||||
|
///
|
||||||
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T>>
|
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T>>
|
||||||
class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
|
class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
|
||||||
public:
|
public:
|
||||||
RefCountedThreadSafe() {}
|
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
||||||
|
cef_subtle::kStartRefCountFromZeroTag;
|
||||||
|
|
||||||
void AddRef() const { cef_subtle::RefCountedThreadSafeBase::AddRef(); }
|
explicit RefCountedThreadSafe()
|
||||||
|
: cef_subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {}
|
||||||
|
|
||||||
|
RefCountedThreadSafe(const RefCountedThreadSafe&) = delete;
|
||||||
|
RefCountedThreadSafe& operator=(const RefCountedThreadSafe&) = delete;
|
||||||
|
|
||||||
|
void AddRef() const { AddRefImpl(T::kRefCountPreference); }
|
||||||
|
|
||||||
void Release() const {
|
void Release() const {
|
||||||
if (cef_subtle::RefCountedThreadSafeBase::Release()) {
|
if (cef_subtle::RefCountedThreadSafeBase::Release()) {
|
||||||
|
ANALYZER_SKIP_THIS_PATH();
|
||||||
Traits::Destruct(static_cast<const T*>(this));
|
Traits::Destruct(static_cast<const T*>(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~RefCountedThreadSafe() {}
|
~RefCountedThreadSafe() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct DefaultRefCountedThreadSafeTraits<T>;
|
friend struct DefaultRefCountedThreadSafeTraits<T>;
|
||||||
static void DeleteInternal(const T* x) { delete x; }
|
template <typename U>
|
||||||
|
static void DeleteInternal(const U* x) {
|
||||||
|
delete x;
|
||||||
|
}
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe);
|
void AddRefImpl(cef_subtle::StartRefCountFromZeroTag) const {
|
||||||
|
cef_subtle::RefCountedThreadSafeBase::AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddRefImpl(cef_subtle::StartRefCountFromOneTag) const {
|
||||||
|
cef_subtle::RefCountedThreadSafeBase::AddRefWithCheck();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
///
|
||||||
// A thread-safe wrapper for some piece of data so we can place other
|
/// A thread-safe wrapper for some piece of data so we can place other
|
||||||
// things in scoped_refptrs<>.
|
/// things in scoped_refptrs<>.
|
||||||
//
|
///
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class RefCountedData
|
class RefCountedData
|
||||||
: public base::RefCountedThreadSafe<base::RefCountedData<T>> {
|
: public base::RefCountedThreadSafe<base::RefCountedData<T>> {
|
||||||
public:
|
public:
|
||||||
RefCountedData() : data() {}
|
RefCountedData() : data() {}
|
||||||
RefCountedData(const T& in_value) : data(in_value) {}
|
RefCountedData(const T& in_value) : data(in_value) {}
|
||||||
|
RefCountedData(T&& in_value) : data(std::move(in_value)) {}
|
||||||
|
template <typename... Args>
|
||||||
|
explicit RefCountedData(std::in_place_t, Args&&... args)
|
||||||
|
: data(std::forward<Args>(args)...) {}
|
||||||
|
|
||||||
T data;
|
T data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class base::RefCountedThreadSafe<base::RefCountedData<T>>;
|
friend class base::RefCountedThreadSafe<base::RefCountedData<T>>;
|
||||||
~RefCountedData() {}
|
~RefCountedData() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool operator==(const RefCountedData<T>& lhs, const RefCountedData<T>& rhs) {
|
||||||
|
return lhs.data == rhs.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool operator!=(const RefCountedData<T>& lhs, const RefCountedData<T>& rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
//
|
|
||||||
// A smart pointer class for reference counted objects. Use this class instead
|
|
||||||
// of calling AddRef and Release manually on a reference counted object to
|
|
||||||
// avoid common memory leaks caused by forgetting to Release an object
|
|
||||||
// reference. Sample usage:
|
|
||||||
//
|
|
||||||
// class MyFoo : public RefCounted<MyFoo> {
|
|
||||||
// ...
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// void some_function() {
|
|
||||||
// scoped_refptr<MyFoo> foo = new MyFoo();
|
|
||||||
// foo->Method(param);
|
|
||||||
// // |foo| is released when this function returns
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void some_other_function() {
|
|
||||||
// scoped_refptr<MyFoo> foo = new MyFoo();
|
|
||||||
// ...
|
|
||||||
// foo = NULL; // explicitly releases |foo|
|
|
||||||
// ...
|
|
||||||
// if (foo)
|
|
||||||
// foo->Method(param);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// The above examples show how scoped_refptr<T> acts like a pointer to T.
|
|
||||||
// Given two scoped_refptr<T> classes, it is also possible to exchange
|
|
||||||
// references between the two objects, like so:
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// scoped_refptr<MyFoo> a = new MyFoo();
|
|
||||||
// scoped_refptr<MyFoo> b;
|
|
||||||
//
|
|
||||||
// b.swap(a);
|
|
||||||
// // now, |b| references the MyFoo object, and |a| references NULL.
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// To make both |a| and |b| in the above example reference the same MyFoo
|
|
||||||
// object, simply use the assignment operator:
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// scoped_refptr<MyFoo> a = new MyFoo();
|
|
||||||
// scoped_refptr<MyFoo> b;
|
|
||||||
//
|
|
||||||
// b = a;
|
|
||||||
// // now, |a| and |b| each own a reference to the same MyFoo object.
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
template <class T>
|
|
||||||
class scoped_refptr {
|
|
||||||
public:
|
|
||||||
typedef T element_type;
|
|
||||||
|
|
||||||
scoped_refptr() : ptr_(NULL) {}
|
|
||||||
|
|
||||||
scoped_refptr(T* p) : ptr_(p) {
|
|
||||||
if (ptr_)
|
|
||||||
ptr_->AddRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr(const scoped_refptr<T>& r) : ptr_(r.ptr_) {
|
|
||||||
if (ptr_)
|
|
||||||
ptr_->AddRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename U>
|
|
||||||
scoped_refptr(const scoped_refptr<U>& r) : ptr_(r.get()) {
|
|
||||||
if (ptr_)
|
|
||||||
ptr_->AddRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
~scoped_refptr() {
|
|
||||||
if (ptr_)
|
|
||||||
ptr_->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
T* get() const { return ptr_; }
|
|
||||||
|
|
||||||
// Allow scoped_refptr<C> to be used in boolean expression
|
|
||||||
// and comparison operations.
|
|
||||||
operator T*() const { return ptr_; }
|
|
||||||
|
|
||||||
T* operator->() const {
|
|
||||||
assert(ptr_ != NULL);
|
|
||||||
return ptr_;
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr<T>& operator=(T* p) {
|
|
||||||
// AddRef first so that self assignment should work
|
|
||||||
if (p)
|
|
||||||
p->AddRef();
|
|
||||||
T* old_ptr = ptr_;
|
|
||||||
ptr_ = p;
|
|
||||||
if (old_ptr)
|
|
||||||
old_ptr->Release();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr<T>& operator=(const scoped_refptr<T>& r) {
|
|
||||||
return *this = r.ptr_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename U>
|
|
||||||
scoped_refptr<T>& operator=(const scoped_refptr<U>& r) {
|
|
||||||
return *this = r.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(T** pp) {
|
|
||||||
T* p = ptr_;
|
|
||||||
ptr_ = *pp;
|
|
||||||
*pp = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(scoped_refptr<T>& r) { swap(&r.ptr_); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
T* ptr_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Handy utility for creating a scoped_refptr<T> out of a T* explicitly without
|
|
||||||
// having to retype all the template arguments
|
|
||||||
template <typename T>
|
|
||||||
scoped_refptr<T> make_scoped_refptr(T* t) {
|
|
||||||
return scoped_refptr<T>(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
#endif // CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_
|
||||||
|
|||||||
@@ -1,625 +0,0 @@
|
|||||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012
|
|
||||||
// Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// Scopers help you manage ownership of a pointer, helping you easily manage a
|
|
||||||
// pointer within a scope, and automatically destroying the pointer at the end
|
|
||||||
// of a scope. There are two main classes you will use, which correspond to the
|
|
||||||
// operators new/delete and new[]/delete[].
|
|
||||||
//
|
|
||||||
// Example usage (scoped_ptr<T>):
|
|
||||||
// {
|
|
||||||
// scoped_ptr<Foo> foo(new Foo("wee"));
|
|
||||||
// } // foo goes out of scope, releasing the pointer with it.
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// scoped_ptr<Foo> foo; // No pointer managed.
|
|
||||||
// foo.reset(new Foo("wee")); // Now a pointer is managed.
|
|
||||||
// foo.reset(new Foo("wee2")); // Foo("wee") was destroyed.
|
|
||||||
// foo.reset(new Foo("wee3")); // Foo("wee2") was destroyed.
|
|
||||||
// foo->Method(); // Foo::Method() called.
|
|
||||||
// foo.get()->Method(); // Foo::Method() called.
|
|
||||||
// SomeFunc(foo.release()); // SomeFunc takes ownership, foo no longer
|
|
||||||
// // manages a pointer.
|
|
||||||
// foo.reset(new Foo("wee4")); // foo manages a pointer again.
|
|
||||||
// foo.reset(); // Foo("wee4") destroyed, foo no longer
|
|
||||||
// // manages a pointer.
|
|
||||||
// } // foo wasn't managing a pointer, so nothing was destroyed.
|
|
||||||
//
|
|
||||||
// Example usage (scoped_ptr<T[]>):
|
|
||||||
// {
|
|
||||||
// scoped_ptr<Foo[]> foo(new Foo[100]);
|
|
||||||
// foo.get()->Method(); // Foo::Method on the 0th element.
|
|
||||||
// foo[10].Method(); // Foo::Method on the 10th element.
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// These scopers also implement part of the functionality of C++11 unique_ptr
|
|
||||||
// in that they are "movable but not copyable." You can use the scopers in
|
|
||||||
// the parameter and return types of functions to signify ownership transfer
|
|
||||||
// in to and out of a function. When calling a function that has a scoper
|
|
||||||
// as the argument type, it must be called with the result of an analogous
|
|
||||||
// scoper's Pass() function or another function that generates a temporary;
|
|
||||||
// passing by copy will NOT work. Here is an example using scoped_ptr:
|
|
||||||
//
|
|
||||||
// void TakesOwnership(scoped_ptr<Foo> arg) {
|
|
||||||
// // Do something with arg
|
|
||||||
// }
|
|
||||||
// scoped_ptr<Foo> CreateFoo() {
|
|
||||||
// // No need for calling Pass() because we are constructing a temporary
|
|
||||||
// // for the return value.
|
|
||||||
// return scoped_ptr<Foo>(new Foo("new"));
|
|
||||||
// }
|
|
||||||
// scoped_ptr<Foo> PassThru(scoped_ptr<Foo> arg) {
|
|
||||||
// return arg.Pass();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// scoped_ptr<Foo> ptr(new Foo("yay")); // ptr manages Foo("yay").
|
|
||||||
// TakesOwnership(ptr.Pass()); // ptr no longer owns Foo("yay").
|
|
||||||
// scoped_ptr<Foo> ptr2 = CreateFoo(); // ptr2 owns the return Foo.
|
|
||||||
// scoped_ptr<Foo> ptr3 = // ptr3 now owns what was in ptr2.
|
|
||||||
// PassThru(ptr2.Pass()); // ptr2 is correspondingly NULL.
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Notice that if you do not call Pass() when returning from PassThru(), or
|
|
||||||
// when invoking TakesOwnership(), the code will not compile because scopers
|
|
||||||
// are not copyable; they only implement move semantics which require calling
|
|
||||||
// the Pass() function to signify a destructive transfer of state. CreateFoo()
|
|
||||||
// is different though because we are constructing a temporary on the return
|
|
||||||
// line and thus can avoid needing to call Pass().
|
|
||||||
//
|
|
||||||
// Pass() properly handles upcast in initialization, i.e. you can use a
|
|
||||||
// scoped_ptr<Child> to initialize a scoped_ptr<Parent>:
|
|
||||||
//
|
|
||||||
// scoped_ptr<Foo> foo(new Foo());
|
|
||||||
// scoped_ptr<FooParent> parent(foo.Pass());
|
|
||||||
//
|
|
||||||
// PassAs<>() should be used to upcast return value in return statement:
|
|
||||||
//
|
|
||||||
// scoped_ptr<Foo> CreateFoo() {
|
|
||||||
// scoped_ptr<FooChild> result(new FooChild());
|
|
||||||
// return result.PassAs<Foo>();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Note that PassAs<>() is implemented only for scoped_ptr<T>, but not for
|
|
||||||
// scoped_ptr<T[]>. This is because casting array pointers may not be safe.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_MEMORY_SCOPED_PTR_H_
|
|
||||||
#define CEF_INCLUDE_BASE_CEF_MEMORY_SCOPED_PTR_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(BASE_MEMORY_SCOPED_PTR_H_)
|
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// Do nothing when building CEF.
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
|
||||||
// The following is substantially similar to the Chromium implementation.
|
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
|
||||||
// updated to match.
|
|
||||||
|
|
||||||
// This is an implementation designed to match the anticipated future TR2
|
|
||||||
// implementation of the scoped_ptr class.
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <algorithm> // For std::swap().
|
|
||||||
|
|
||||||
#include "include/base/cef_basictypes.h"
|
|
||||||
#include "include/base/cef_build.h"
|
|
||||||
#include "include/base/cef_macros.h"
|
|
||||||
#include "include/base/cef_move.h"
|
|
||||||
#include "include/base/cef_template_util.h"
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
|
|
||||||
namespace subtle {
|
|
||||||
class RefCountedBase;
|
|
||||||
class RefCountedThreadSafeBase;
|
|
||||||
} // namespace subtle
|
|
||||||
|
|
||||||
// Function object which deletes its parameter, which must be a pointer.
|
|
||||||
// If C is an array type, invokes 'delete[]' on the parameter; otherwise,
|
|
||||||
// invokes 'delete'. The default deleter for scoped_ptr<T>.
|
|
||||||
template <class T>
|
|
||||||
struct DefaultDeleter {
|
|
||||||
DefaultDeleter() {}
|
|
||||||
template <typename U>
|
|
||||||
DefaultDeleter(const DefaultDeleter<U>& other) {
|
|
||||||
// IMPLEMENTATION NOTE: C++11 20.7.1.1.2p2 only provides this constructor
|
|
||||||
// if U* is implicitly convertible to T* and U is not an array type.
|
|
||||||
//
|
|
||||||
// Correct implementation should use SFINAE to disable this
|
|
||||||
// constructor. However, since there are no other 1-argument constructors,
|
|
||||||
// using a COMPILE_ASSERT() based on is_convertible<> and requiring
|
|
||||||
// complete types is simpler and will cause compile failures for equivalent
|
|
||||||
// misuses.
|
|
||||||
//
|
|
||||||
// Note, the is_convertible<U*, T*> check also ensures that U is not an
|
|
||||||
// array. T is guaranteed to be a non-array, so any U* where U is an array
|
|
||||||
// cannot convert to T*.
|
|
||||||
enum { T_must_be_complete = sizeof(T) };
|
|
||||||
enum { U_must_be_complete = sizeof(U) };
|
|
||||||
COMPILE_ASSERT((base::is_convertible<U*, T*>::value),
|
|
||||||
U_ptr_must_implicitly_convert_to_T_ptr);
|
|
||||||
}
|
|
||||||
inline void operator()(T* ptr) const {
|
|
||||||
enum { type_must_be_complete = sizeof(T) };
|
|
||||||
delete ptr;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Specialization of DefaultDeleter for array types.
|
|
||||||
template <class T>
|
|
||||||
struct DefaultDeleter<T[]> {
|
|
||||||
inline void operator()(T* ptr) const {
|
|
||||||
enum { type_must_be_complete = sizeof(T) };
|
|
||||||
delete[] ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Disable this operator for any U != T because it is undefined to execute
|
|
||||||
// an array delete when the static type of the array mismatches the dynamic
|
|
||||||
// type.
|
|
||||||
//
|
|
||||||
// References:
|
|
||||||
// C++98 [expr.delete]p3
|
|
||||||
// http://cplusplus.github.com/LWG/lwg-defects.html#938
|
|
||||||
template <typename U>
|
|
||||||
void operator()(U* array) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, int n>
|
|
||||||
struct DefaultDeleter<T[n]> {
|
|
||||||
// Never allow someone to declare something like scoped_ptr<int[10]>.
|
|
||||||
COMPILE_ASSERT(sizeof(T) == -1, do_not_use_array_with_size_as_type);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Function object which invokes 'free' on its parameter, which must be
|
|
||||||
// a pointer. Can be used to store malloc-allocated pointers in scoped_ptr:
|
|
||||||
//
|
|
||||||
// scoped_ptr<int, base::FreeDeleter> foo_ptr(
|
|
||||||
// static_cast<int*>(malloc(sizeof(int))));
|
|
||||||
struct FreeDeleter {
|
|
||||||
inline void operator()(void* ptr) const { free(ptr); }
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace cef_internal {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct IsNotRefCounted {
|
|
||||||
enum {
|
|
||||||
value =
|
|
||||||
!base::is_convertible<T*, base::subtle::RefCountedBase*>::value &&
|
|
||||||
!base::is_convertible<T*,
|
|
||||||
base::subtle::RefCountedThreadSafeBase*>::value
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Minimal implementation of the core logic of scoped_ptr, suitable for
|
|
||||||
// reuse in both scoped_ptr and its specializations.
|
|
||||||
template <class T, class D>
|
|
||||||
class scoped_ptr_impl {
|
|
||||||
public:
|
|
||||||
explicit scoped_ptr_impl(T* p) : data_(p) {}
|
|
||||||
|
|
||||||
// Initializer for deleters that have data parameters.
|
|
||||||
scoped_ptr_impl(T* p, const D& d) : data_(p, d) {}
|
|
||||||
|
|
||||||
// Templated constructor that destructively takes the value from another
|
|
||||||
// scoped_ptr_impl.
|
|
||||||
template <typename U, typename V>
|
|
||||||
scoped_ptr_impl(scoped_ptr_impl<U, V>* other)
|
|
||||||
: data_(other->release(), other->get_deleter()) {
|
|
||||||
// We do not support move-only deleters. We could modify our move
|
|
||||||
// emulation to have base::subtle::move() and base::subtle::forward()
|
|
||||||
// functions that are imperfect emulations of their C++11 equivalents,
|
|
||||||
// but until there's a requirement, just assume deleters are copyable.
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename U, typename V>
|
|
||||||
void TakeState(scoped_ptr_impl<U, V>* other) {
|
|
||||||
// See comment in templated constructor above regarding lack of support
|
|
||||||
// for move-only deleters.
|
|
||||||
reset(other->release());
|
|
||||||
get_deleter() = other->get_deleter();
|
|
||||||
}
|
|
||||||
|
|
||||||
~scoped_ptr_impl() {
|
|
||||||
if (data_.ptr != NULL) {
|
|
||||||
// Not using get_deleter() saves one function call in non-optimized
|
|
||||||
// builds.
|
|
||||||
static_cast<D&>(data_)(data_.ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset(T* p) {
|
|
||||||
// This is a self-reset, which is no longer allowed: http://crbug.com/162971
|
|
||||||
if (p != NULL && p == data_.ptr)
|
|
||||||
abort();
|
|
||||||
|
|
||||||
// Note that running data_.ptr = p can lead to undefined behavior if
|
|
||||||
// get_deleter()(get()) deletes this. In order to prevent this, reset()
|
|
||||||
// should update the stored pointer before deleting its old value.
|
|
||||||
//
|
|
||||||
// However, changing reset() to use that behavior may cause current code to
|
|
||||||
// break in unexpected ways. If the destruction of the owned object
|
|
||||||
// dereferences the scoped_ptr when it is destroyed by a call to reset(),
|
|
||||||
// then it will incorrectly dispatch calls to |p| rather than the original
|
|
||||||
// value of |data_.ptr|.
|
|
||||||
//
|
|
||||||
// During the transition period, set the stored pointer to NULL while
|
|
||||||
// deleting the object. Eventually, this safety check will be removed to
|
|
||||||
// prevent the scenario initially described from occuring and
|
|
||||||
// http://crbug.com/176091 can be closed.
|
|
||||||
T* old = data_.ptr;
|
|
||||||
data_.ptr = NULL;
|
|
||||||
if (old != NULL)
|
|
||||||
static_cast<D&>(data_)(old);
|
|
||||||
data_.ptr = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
T* get() const { return data_.ptr; }
|
|
||||||
|
|
||||||
D& get_deleter() { return data_; }
|
|
||||||
const D& get_deleter() const { return data_; }
|
|
||||||
|
|
||||||
void swap(scoped_ptr_impl& p2) {
|
|
||||||
// Standard swap idiom: 'using std::swap' ensures that std::swap is
|
|
||||||
// present in the overload set, but we call swap unqualified so that
|
|
||||||
// any more-specific overloads can be used, if available.
|
|
||||||
using std::swap;
|
|
||||||
swap(static_cast<D&>(data_), static_cast<D&>(p2.data_));
|
|
||||||
swap(data_.ptr, p2.data_.ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
T* release() {
|
|
||||||
T* old_ptr = data_.ptr;
|
|
||||||
data_.ptr = NULL;
|
|
||||||
return old_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Needed to allow type-converting constructor.
|
|
||||||
template <typename U, typename V>
|
|
||||||
friend class scoped_ptr_impl;
|
|
||||||
|
|
||||||
// Use the empty base class optimization to allow us to have a D
|
|
||||||
// member, while avoiding any space overhead for it when D is an
|
|
||||||
// empty class. See e.g. http://www.cantrip.org/emptyopt.html for a good
|
|
||||||
// discussion of this technique.
|
|
||||||
struct Data : public D {
|
|
||||||
explicit Data(T* ptr_in) : ptr(ptr_in) {}
|
|
||||||
Data(T* ptr_in, const D& other) : D(other), ptr(ptr_in) {}
|
|
||||||
T* ptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
Data data_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(scoped_ptr_impl);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace cef_internal
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
// A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>
|
|
||||||
// automatically deletes the pointer it holds (if any).
|
|
||||||
// That is, scoped_ptr<T> owns the T object that it points to.
|
|
||||||
// Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.
|
|
||||||
// Also like T*, scoped_ptr<T> is thread-compatible, and once you
|
|
||||||
// dereference it, you get the thread safety guarantees of T.
|
|
||||||
//
|
|
||||||
// The size of scoped_ptr is small. On most compilers, when using the
|
|
||||||
// DefaultDeleter, sizeof(scoped_ptr<T>) == sizeof(T*). Custom deleters will
|
|
||||||
// increase the size proportional to whatever state they need to have. See
|
|
||||||
// comments inside scoped_ptr_impl<> for details.
|
|
||||||
//
|
|
||||||
// Current implementation targets having a strict subset of C++11's
|
|
||||||
// unique_ptr<> features. Known deficiencies include not supporting move-only
|
|
||||||
// deleteres, function pointers as deleters, and deleters with reference
|
|
||||||
// types.
|
|
||||||
template <class T, class D = base::DefaultDeleter<T>>
|
|
||||||
class scoped_ptr {
|
|
||||||
MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
|
|
||||||
|
|
||||||
COMPILE_ASSERT(base::cef_internal::IsNotRefCounted<T>::value,
|
|
||||||
T_is_refcounted_type_and_needs_scoped_refptr);
|
|
||||||
|
|
||||||
public:
|
|
||||||
// The element and deleter types.
|
|
||||||
typedef T element_type;
|
|
||||||
typedef D deleter_type;
|
|
||||||
|
|
||||||
// Constructor. Defaults to initializing with NULL.
|
|
||||||
scoped_ptr() : impl_(NULL) {}
|
|
||||||
|
|
||||||
// Constructor. Takes ownership of p.
|
|
||||||
explicit scoped_ptr(element_type* p) : impl_(p) {}
|
|
||||||
|
|
||||||
// Constructor. Allows initialization of a stateful deleter.
|
|
||||||
scoped_ptr(element_type* p, const D& d) : impl_(p, d) {}
|
|
||||||
|
|
||||||
// Constructor. Allows construction from a scoped_ptr rvalue for a
|
|
||||||
// convertible type and deleter.
|
|
||||||
//
|
|
||||||
// IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this constructor distinct
|
|
||||||
// from the normal move constructor. By C++11 20.7.1.2.1.21, this constructor
|
|
||||||
// has different post-conditions if D is a reference type. Since this
|
|
||||||
// implementation does not support deleters with reference type,
|
|
||||||
// we do not need a separate move constructor allowing us to avoid one
|
|
||||||
// use of SFINAE. You only need to care about this if you modify the
|
|
||||||
// implementation of scoped_ptr.
|
|
||||||
template <typename U, typename V>
|
|
||||||
scoped_ptr(scoped_ptr<U, V> other) : impl_(&other.impl_) {
|
|
||||||
COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constructor. Move constructor for C++03 move emulation of this type.
|
|
||||||
scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) {}
|
|
||||||
|
|
||||||
// operator=. Allows assignment from a scoped_ptr rvalue for a convertible
|
|
||||||
// type and deleter.
|
|
||||||
//
|
|
||||||
// IMPLEMENTATION NOTE: C++11 unique_ptr<> keeps this operator= distinct from
|
|
||||||
// the normal move assignment operator. By C++11 20.7.1.2.3.4, this templated
|
|
||||||
// form has different requirements on for move-only Deleters. Since this
|
|
||||||
// implementation does not support move-only Deleters, we do not need a
|
|
||||||
// separate move assignment operator allowing us to avoid one use of SFINAE.
|
|
||||||
// You only need to care about this if you modify the implementation of
|
|
||||||
// scoped_ptr.
|
|
||||||
template <typename U, typename V>
|
|
||||||
scoped_ptr& operator=(scoped_ptr<U, V> rhs) {
|
|
||||||
COMPILE_ASSERT(!base::is_array<U>::value, U_cannot_be_an_array);
|
|
||||||
impl_.TakeState(&rhs.impl_);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset. Deletes the currently owned object, if any.
|
|
||||||
// Then takes ownership of a new object, if given.
|
|
||||||
void reset(element_type* p = NULL) { impl_.reset(p); }
|
|
||||||
|
|
||||||
// Accessors to get the owned object.
|
|
||||||
// operator* and operator-> will assert() if there is no current object.
|
|
||||||
element_type& operator*() const {
|
|
||||||
assert(impl_.get() != NULL);
|
|
||||||
return *impl_.get();
|
|
||||||
}
|
|
||||||
element_type* operator->() const {
|
|
||||||
assert(impl_.get() != NULL);
|
|
||||||
return impl_.get();
|
|
||||||
}
|
|
||||||
element_type* get() const { return impl_.get(); }
|
|
||||||
|
|
||||||
// Access to the deleter.
|
|
||||||
deleter_type& get_deleter() { return impl_.get_deleter(); }
|
|
||||||
const deleter_type& get_deleter() const { return impl_.get_deleter(); }
|
|
||||||
|
|
||||||
// Allow scoped_ptr<element_type> to be used in boolean expressions, but not
|
|
||||||
// implicitly convertible to a real bool (which is dangerous).
|
|
||||||
//
|
|
||||||
// Note that this trick is only safe when the == and != operators
|
|
||||||
// are declared explicitly, as otherwise "scoped_ptr1 ==
|
|
||||||
// scoped_ptr2" will compile but do the wrong thing (i.e., convert
|
|
||||||
// to Testable and then do the comparison).
|
|
||||||
private:
|
|
||||||
typedef base::cef_internal::scoped_ptr_impl<element_type, deleter_type>
|
|
||||||
scoped_ptr::*Testable;
|
|
||||||
|
|
||||||
public:
|
|
||||||
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
|
|
||||||
|
|
||||||
// Comparison operators.
|
|
||||||
// These return whether two scoped_ptr refer to the same object, not just to
|
|
||||||
// two different but equal objects.
|
|
||||||
bool operator==(const element_type* p) const { return impl_.get() == p; }
|
|
||||||
bool operator!=(const element_type* p) const { return impl_.get() != p; }
|
|
||||||
|
|
||||||
// Swap two scoped pointers.
|
|
||||||
void swap(scoped_ptr& p2) { impl_.swap(p2.impl_); }
|
|
||||||
|
|
||||||
// Release a pointer.
|
|
||||||
// The return value is the current pointer held by this object.
|
|
||||||
// If this object holds a NULL pointer, the return value is NULL.
|
|
||||||
// After this operation, this object will hold a NULL pointer,
|
|
||||||
// and will not own the object any more.
|
|
||||||
element_type* release() WARN_UNUSED_RESULT { return impl_.release(); }
|
|
||||||
|
|
||||||
// C++98 doesn't support functions templates with default parameters which
|
|
||||||
// makes it hard to write a PassAs() that understands converting the deleter
|
|
||||||
// while preserving simple calling semantics.
|
|
||||||
//
|
|
||||||
// Until there is a use case for PassAs() with custom deleters, just ignore
|
|
||||||
// the custom deleter.
|
|
||||||
template <typename PassAsType>
|
|
||||||
scoped_ptr<PassAsType> PassAs() {
|
|
||||||
return scoped_ptr<PassAsType>(Pass());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Needed to reach into |impl_| in the constructor.
|
|
||||||
template <typename U, typename V>
|
|
||||||
friend class scoped_ptr;
|
|
||||||
base::cef_internal::scoped_ptr_impl<element_type, deleter_type> impl_;
|
|
||||||
|
|
||||||
// Forbidden for API compatibility with std::unique_ptr.
|
|
||||||
explicit scoped_ptr(int disallow_construction_from_null);
|
|
||||||
|
|
||||||
// Forbid comparison of scoped_ptr types. If U != T, it totally
|
|
||||||
// doesn't make sense, and if U == T, it still doesn't make sense
|
|
||||||
// because you should never have the same object owned by two different
|
|
||||||
// scoped_ptrs.
|
|
||||||
template <class U>
|
|
||||||
bool operator==(scoped_ptr<U> const& p2) const;
|
|
||||||
template <class U>
|
|
||||||
bool operator!=(scoped_ptr<U> const& p2) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, class D>
|
|
||||||
class scoped_ptr<T[], D> {
|
|
||||||
MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
|
|
||||||
|
|
||||||
public:
|
|
||||||
// The element and deleter types.
|
|
||||||
typedef T element_type;
|
|
||||||
typedef D deleter_type;
|
|
||||||
|
|
||||||
// Constructor. Defaults to initializing with NULL.
|
|
||||||
scoped_ptr() : impl_(NULL) {}
|
|
||||||
|
|
||||||
// Constructor. Stores the given array. Note that the argument's type
|
|
||||||
// must exactly match T*. In particular:
|
|
||||||
// - it cannot be a pointer to a type derived from T, because it is
|
|
||||||
// inherently unsafe in the general case to access an array through a
|
|
||||||
// pointer whose dynamic type does not match its static type (eg., if
|
|
||||||
// T and the derived types had different sizes access would be
|
|
||||||
// incorrectly calculated). Deletion is also always undefined
|
|
||||||
// (C++98 [expr.delete]p3). If you're doing this, fix your code.
|
|
||||||
// - it cannot be NULL, because NULL is an integral expression, not a
|
|
||||||
// pointer to T. Use the no-argument version instead of explicitly
|
|
||||||
// passing NULL.
|
|
||||||
// - it cannot be const-qualified differently from T per unique_ptr spec
|
|
||||||
// (http://cplusplus.github.com/LWG/lwg-active.html#2118). Users wanting
|
|
||||||
// to work around this may use implicit_cast<const T*>().
|
|
||||||
// However, because of the first bullet in this comment, users MUST
|
|
||||||
// NOT use implicit_cast<Base*>() to upcast the static type of the array.
|
|
||||||
explicit scoped_ptr(element_type* array) : impl_(array) {}
|
|
||||||
|
|
||||||
// Constructor. Move constructor for C++03 move emulation of this type.
|
|
||||||
scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) {}
|
|
||||||
|
|
||||||
// operator=. Move operator= for C++03 move emulation of this type.
|
|
||||||
scoped_ptr& operator=(RValue rhs) {
|
|
||||||
impl_.TakeState(&rhs.object->impl_);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset. Deletes the currently owned array, if any.
|
|
||||||
// Then takes ownership of a new object, if given.
|
|
||||||
void reset(element_type* array = NULL) { impl_.reset(array); }
|
|
||||||
|
|
||||||
// Accessors to get the owned array.
|
|
||||||
element_type& operator[](size_t i) const {
|
|
||||||
assert(impl_.get() != NULL);
|
|
||||||
return impl_.get()[i];
|
|
||||||
}
|
|
||||||
element_type* get() const { return impl_.get(); }
|
|
||||||
|
|
||||||
// Access to the deleter.
|
|
||||||
deleter_type& get_deleter() { return impl_.get_deleter(); }
|
|
||||||
const deleter_type& get_deleter() const { return impl_.get_deleter(); }
|
|
||||||
|
|
||||||
// Allow scoped_ptr<element_type> to be used in boolean expressions, but not
|
|
||||||
// implicitly convertible to a real bool (which is dangerous).
|
|
||||||
private:
|
|
||||||
typedef base::cef_internal::scoped_ptr_impl<element_type, deleter_type>
|
|
||||||
scoped_ptr::*Testable;
|
|
||||||
|
|
||||||
public:
|
|
||||||
operator Testable() const { return impl_.get() ? &scoped_ptr::impl_ : NULL; }
|
|
||||||
|
|
||||||
// Comparison operators.
|
|
||||||
// These return whether two scoped_ptr refer to the same object, not just to
|
|
||||||
// two different but equal objects.
|
|
||||||
bool operator==(element_type* array) const { return impl_.get() == array; }
|
|
||||||
bool operator!=(element_type* array) const { return impl_.get() != array; }
|
|
||||||
|
|
||||||
// Swap two scoped pointers.
|
|
||||||
void swap(scoped_ptr& p2) { impl_.swap(p2.impl_); }
|
|
||||||
|
|
||||||
// Release a pointer.
|
|
||||||
// The return value is the current pointer held by this object.
|
|
||||||
// If this object holds a NULL pointer, the return value is NULL.
|
|
||||||
// After this operation, this object will hold a NULL pointer,
|
|
||||||
// and will not own the object any more.
|
|
||||||
element_type* release() WARN_UNUSED_RESULT { return impl_.release(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Force element_type to be a complete type.
|
|
||||||
enum { type_must_be_complete = sizeof(element_type) };
|
|
||||||
|
|
||||||
// Actually hold the data.
|
|
||||||
base::cef_internal::scoped_ptr_impl<element_type, deleter_type> impl_;
|
|
||||||
|
|
||||||
// Disable initialization from any type other than element_type*, by
|
|
||||||
// providing a constructor that matches such an initialization, but is
|
|
||||||
// private and has no definition. This is disabled because it is not safe to
|
|
||||||
// call delete[] on an array whose static type does not match its dynamic
|
|
||||||
// type.
|
|
||||||
template <typename U>
|
|
||||||
explicit scoped_ptr(U* array);
|
|
||||||
explicit scoped_ptr(int disallow_construction_from_null);
|
|
||||||
|
|
||||||
// Disable reset() from any type other than element_type*, for the same
|
|
||||||
// reasons as the constructor above.
|
|
||||||
template <typename U>
|
|
||||||
void reset(U* array);
|
|
||||||
void reset(int disallow_reset_from_null);
|
|
||||||
|
|
||||||
// Forbid comparison of scoped_ptr types. If U != T, it totally
|
|
||||||
// doesn't make sense, and if U == T, it still doesn't make sense
|
|
||||||
// because you should never have the same object owned by two different
|
|
||||||
// scoped_ptrs.
|
|
||||||
template <class U>
|
|
||||||
bool operator==(scoped_ptr<U> const& p2) const;
|
|
||||||
template <class U>
|
|
||||||
bool operator!=(scoped_ptr<U> const& p2) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Free functions
|
|
||||||
template <class T, class D>
|
|
||||||
void swap(scoped_ptr<T, D>& p1, scoped_ptr<T, D>& p2) {
|
|
||||||
p1.swap(p2);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class D>
|
|
||||||
bool operator==(T* p1, const scoped_ptr<T, D>& p2) {
|
|
||||||
return p1 == p2.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T, class D>
|
|
||||||
bool operator!=(T* p1, const scoped_ptr<T, D>& p2) {
|
|
||||||
return p1 != p2.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
// A function to convert T* into scoped_ptr<T>
|
|
||||||
// Doing e.g. make_scoped_ptr(new FooBarBaz<type>(arg)) is a shorter notation
|
|
||||||
// for scoped_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))
|
|
||||||
template <typename T>
|
|
||||||
scoped_ptr<T> make_scoped_ptr(T* ptr) {
|
|
||||||
return scoped_ptr<T>(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_MEMORY_SCOPED_PTR_H_
|
|
||||||
420
include/base/cef_scoped_refptr.h
Normal file
420
include/base/cef_scoped_refptr.h
Normal file
@@ -0,0 +1,420 @@
|
|||||||
|
// Copyright (c) 2017 Marshall A. Greenblatt. Portions copyright (c) 2011
|
||||||
|
// Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_SCOPED_REFPTR_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_SCOPED_REFPTR_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/memory/scoped_refptr.h"
|
||||||
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
|
// The following is substantially similar to the Chromium implementation.
|
||||||
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
|
// updated to match.
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "include/base/cef_logging.h"
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class scoped_refptr;
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
template <class, typename>
|
||||||
|
class RefCounted;
|
||||||
|
template <class, typename>
|
||||||
|
class RefCountedThreadSafe;
|
||||||
|
class SequencedTaskRunner;
|
||||||
|
class WrappedPromise;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
scoped_refptr<T> AdoptRef(T* t);
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
class BasePromise;
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
|
||||||
|
namespace cef_subtle {
|
||||||
|
|
||||||
|
enum AdoptRefTag { kAdoptRefTag };
|
||||||
|
enum StartRefCountFromZeroTag { kStartRefCountFromZeroTag };
|
||||||
|
enum StartRefCountFromOneTag { kStartRefCountFromOneTag };
|
||||||
|
|
||||||
|
template <typename T, typename U, typename V>
|
||||||
|
constexpr bool IsRefCountPreferenceOverridden(const T*,
|
||||||
|
const RefCounted<U, V>*) {
|
||||||
|
return !std::is_same<std::decay_t<decltype(T::kRefCountPreference)>,
|
||||||
|
std::decay_t<decltype(U::kRefCountPreference)>>::value;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U, typename V>
|
||||||
|
constexpr bool IsRefCountPreferenceOverridden(
|
||||||
|
const T*,
|
||||||
|
const RefCountedThreadSafe<U, V>*) {
|
||||||
|
return !std::is_same<std::decay_t<decltype(T::kRefCountPreference)>,
|
||||||
|
std::decay_t<decltype(U::kRefCountPreference)>>::value;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool IsRefCountPreferenceOverridden(...) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cef_subtle
|
||||||
|
|
||||||
|
// Creates a scoped_refptr from a raw pointer without incrementing the reference
|
||||||
|
// count. Use this only for a newly created object whose reference count starts
|
||||||
|
// from 1 instead of 0.
|
||||||
|
template <typename T>
|
||||||
|
scoped_refptr<T> AdoptRef(T* obj) {
|
||||||
|
using Tag = std::decay_t<decltype(T::kRefCountPreference)>;
|
||||||
|
static_assert(std::is_same<cef_subtle::StartRefCountFromOneTag, Tag>::value,
|
||||||
|
"Use AdoptRef only if the reference count starts from one.");
|
||||||
|
|
||||||
|
DCHECK(obj);
|
||||||
|
DCHECK(obj->HasOneRef());
|
||||||
|
obj->Adopted();
|
||||||
|
return scoped_refptr<T>(obj, cef_subtle::kAdoptRefTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace cef_subtle {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
scoped_refptr<T> AdoptRefIfNeeded(T* obj, StartRefCountFromZeroTag) {
|
||||||
|
return scoped_refptr<T>(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
scoped_refptr<T> AdoptRefIfNeeded(T* obj, StartRefCountFromOneTag) {
|
||||||
|
return AdoptRef(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cef_subtle
|
||||||
|
|
||||||
|
// Constructs an instance of T, which is a ref counted type, and wraps the
|
||||||
|
// object into a scoped_refptr<T>.
|
||||||
|
template <typename T, typename... Args>
|
||||||
|
scoped_refptr<T> MakeRefCounted(Args&&... args) {
|
||||||
|
T* obj = new T(std::forward<Args>(args)...);
|
||||||
|
return cef_subtle::AdoptRefIfNeeded(obj, T::kRefCountPreference);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Takes an instance of T, which is a ref counted type, and wraps the object
|
||||||
|
// into a scoped_refptr<T>.
|
||||||
|
template <typename T>
|
||||||
|
scoped_refptr<T> WrapRefCounted(T* t) {
|
||||||
|
return scoped_refptr<T>(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A smart pointer class for reference counted objects. Use this class instead
|
||||||
|
/// of calling AddRef and Release manually on a reference counted object to
|
||||||
|
/// avoid common memory leaks caused by forgetting to Release an object
|
||||||
|
/// reference. Sample usage:
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// class MyFoo : public RefCounted<MyFoo> {
|
||||||
|
/// ...
|
||||||
|
/// private:
|
||||||
|
/// friend class RefCounted<MyFoo>; // Allow destruction by RefCounted<>.
|
||||||
|
/// ~MyFoo(); // Destructor must be
|
||||||
|
/// private/protected.
|
||||||
|
/// };
|
||||||
|
///
|
||||||
|
/// void some_function() {
|
||||||
|
/// scoped_refptr<MyFoo> foo = MakeRefCounted<MyFoo>();
|
||||||
|
/// foo->Method(param);
|
||||||
|
/// // |foo| is released when this function returns
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// void some_other_function() {
|
||||||
|
/// scoped_refptr<MyFoo> foo = MakeRefCounted<MyFoo>();
|
||||||
|
/// ...
|
||||||
|
/// foo.reset(); // explicitly releases |foo|
|
||||||
|
/// ...
|
||||||
|
/// if (foo)
|
||||||
|
/// foo->Method(param);
|
||||||
|
/// }
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// The above examples show how scoped_refptr<T> acts like a pointer to T.
|
||||||
|
/// Given two scoped_refptr<T> classes, it is also possible to exchange
|
||||||
|
/// references between the two objects, like so:
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// {
|
||||||
|
/// scoped_refptr<MyFoo> a = MakeRefCounted<MyFoo>();
|
||||||
|
/// scoped_refptr<MyFoo> b;
|
||||||
|
///
|
||||||
|
/// b.swap(a);
|
||||||
|
/// // now, |b| references the MyFoo object, and |a| references nullptr.
|
||||||
|
/// }
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// To make both |a| and |b| in the above example reference the same MyFoo
|
||||||
|
/// object, simply use the assignment operator:
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// {
|
||||||
|
/// scoped_refptr<MyFoo> a = MakeRefCounted<MyFoo>();
|
||||||
|
/// scoped_refptr<MyFoo> b;
|
||||||
|
///
|
||||||
|
/// b = a;
|
||||||
|
/// // now, |a| and |b| each own a reference to the same MyFoo object.
|
||||||
|
/// }
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// Also see Chromium's ownership and calling conventions:
|
||||||
|
/// https://chromium.googlesource.com/chromium/src/+/lkgr/styleguide/c++/c++.md#object-ownership-and-calling-conventions
|
||||||
|
/// Specifically:
|
||||||
|
/// If the function (at least sometimes) takes a ref on a refcounted object,
|
||||||
|
/// declare the param as scoped_refptr<T>. The caller can decide whether it
|
||||||
|
/// wishes to transfer ownership (by calling std::move(t) when passing t) or
|
||||||
|
/// retain its ref (by simply passing t directly).
|
||||||
|
/// In other words, use scoped_refptr like you would a std::unique_ptr except
|
||||||
|
/// in the odd case where it's required to hold on to a ref while handing one
|
||||||
|
/// to another component (if a component merely needs to use t on the stack
|
||||||
|
/// without keeping a ref: pass t as a raw T*).
|
||||||
|
///
|
||||||
|
template <class T>
|
||||||
|
class TRIVIAL_ABI scoped_refptr {
|
||||||
|
public:
|
||||||
|
typedef T element_type;
|
||||||
|
|
||||||
|
constexpr scoped_refptr() = default;
|
||||||
|
|
||||||
|
// Allow implicit construction from nullptr.
|
||||||
|
constexpr scoped_refptr(std::nullptr_t) {}
|
||||||
|
|
||||||
|
// Constructs from a raw pointer. Note that this constructor allows implicit
|
||||||
|
// conversion from T* to scoped_refptr<T> which is strongly discouraged. If
|
||||||
|
// you are creating a new ref-counted object please use
|
||||||
|
// base::MakeRefCounted<T>() or base::WrapRefCounted<T>(). Otherwise you
|
||||||
|
// should move or copy construct from an existing scoped_refptr<T> to the
|
||||||
|
// ref-counted object.
|
||||||
|
scoped_refptr(T* p) : ptr_(p) {
|
||||||
|
if (ptr_) {
|
||||||
|
AddRef(ptr_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy constructor. This is required in addition to the copy conversion
|
||||||
|
// constructor below.
|
||||||
|
scoped_refptr(const scoped_refptr& r) : scoped_refptr(r.ptr_) {}
|
||||||
|
|
||||||
|
// Copy conversion constructor.
|
||||||
|
template <typename U,
|
||||||
|
typename = typename std::enable_if<
|
||||||
|
std::is_convertible<U*, T*>::value>::type>
|
||||||
|
scoped_refptr(const scoped_refptr<U>& r) : scoped_refptr(r.ptr_) {}
|
||||||
|
|
||||||
|
// Move constructor. This is required in addition to the move conversion
|
||||||
|
// constructor below.
|
||||||
|
scoped_refptr(scoped_refptr&& r) noexcept : ptr_(r.ptr_) { r.ptr_ = nullptr; }
|
||||||
|
|
||||||
|
// Move conversion constructor.
|
||||||
|
template <typename U,
|
||||||
|
typename = typename std::enable_if<
|
||||||
|
std::is_convertible<U*, T*>::value>::type>
|
||||||
|
scoped_refptr(scoped_refptr<U>&& r) noexcept : ptr_(r.ptr_) {
|
||||||
|
r.ptr_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
~scoped_refptr() {
|
||||||
|
static_assert(!base::cef_subtle::IsRefCountPreferenceOverridden(
|
||||||
|
static_cast<T*>(nullptr), static_cast<T*>(nullptr)),
|
||||||
|
"It's unsafe to override the ref count preference."
|
||||||
|
" Please remove REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE"
|
||||||
|
" from subclasses.");
|
||||||
|
if (ptr_) {
|
||||||
|
Release(ptr_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
T* get() const { return ptr_; }
|
||||||
|
|
||||||
|
T& operator*() const {
|
||||||
|
DCHECK(ptr_);
|
||||||
|
return *ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* operator->() const {
|
||||||
|
DCHECK(ptr_);
|
||||||
|
return ptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
scoped_refptr& operator=(std::nullptr_t) {
|
||||||
|
reset();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
scoped_refptr& operator=(T* p) { return *this = scoped_refptr(p); }
|
||||||
|
|
||||||
|
// Unified assignment operator.
|
||||||
|
scoped_refptr& operator=(scoped_refptr r) noexcept {
|
||||||
|
swap(r);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets managed object to null and releases reference to the previous managed
|
||||||
|
// object, if it existed.
|
||||||
|
void reset() { scoped_refptr().swap(*this); }
|
||||||
|
|
||||||
|
// Returns the owned pointer (if any), releasing ownership to the caller. The
|
||||||
|
// caller is responsible for managing the lifetime of the reference.
|
||||||
|
[[nodiscard]] T* release();
|
||||||
|
|
||||||
|
void swap(scoped_refptr& r) noexcept { std::swap(ptr_, r.ptr_); }
|
||||||
|
|
||||||
|
explicit operator bool() const { return ptr_ != nullptr; }
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
bool operator==(const scoped_refptr<U>& rhs) const {
|
||||||
|
return ptr_ == rhs.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
bool operator!=(const scoped_refptr<U>& rhs) const {
|
||||||
|
return !operator==(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename U>
|
||||||
|
bool operator<(const scoped_refptr<U>& rhs) const {
|
||||||
|
return ptr_ < rhs.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
T* ptr_ = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename U>
|
||||||
|
friend scoped_refptr<U> base::AdoptRef(U*);
|
||||||
|
friend class ::base::SequencedTaskRunner;
|
||||||
|
|
||||||
|
// Friend access so these classes can use the constructor below as part of a
|
||||||
|
// binary size optimization.
|
||||||
|
friend class ::base::internal::BasePromise;
|
||||||
|
friend class ::base::WrappedPromise;
|
||||||
|
|
||||||
|
scoped_refptr(T* p, base::cef_subtle::AdoptRefTag) : ptr_(p) {}
|
||||||
|
|
||||||
|
// Friend required for move constructors that set r.ptr_ to null.
|
||||||
|
template <typename U>
|
||||||
|
friend class scoped_refptr;
|
||||||
|
|
||||||
|
// Non-inline helpers to allow:
|
||||||
|
// class Opaque;
|
||||||
|
// extern template class scoped_refptr<Opaque>;
|
||||||
|
// Otherwise the compiler will complain that Opaque is an incomplete type.
|
||||||
|
static void AddRef(T* ptr);
|
||||||
|
static void Release(T* ptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T* scoped_refptr<T>::release() {
|
||||||
|
T* ptr = ptr_;
|
||||||
|
ptr_ = nullptr;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
template <typename T>
|
||||||
|
void scoped_refptr<T>::AddRef(T* ptr) {
|
||||||
|
ptr->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
template <typename T>
|
||||||
|
void scoped_refptr<T>::Release(T* ptr) {
|
||||||
|
ptr->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
bool operator==(const scoped_refptr<T>& lhs, const U* rhs) {
|
||||||
|
return lhs.get() == rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
bool operator==(const T* lhs, const scoped_refptr<U>& rhs) {
|
||||||
|
return lhs == rhs.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool operator==(const scoped_refptr<T>& lhs, std::nullptr_t null) {
|
||||||
|
return !static_cast<bool>(lhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool operator==(std::nullptr_t null, const scoped_refptr<T>& rhs) {
|
||||||
|
return !static_cast<bool>(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
bool operator!=(const scoped_refptr<T>& lhs, const U* rhs) {
|
||||||
|
return !operator==(lhs, rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) {
|
||||||
|
return !operator==(lhs, rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool operator!=(const scoped_refptr<T>& lhs, std::nullptr_t null) {
|
||||||
|
return !operator==(lhs, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool operator!=(std::nullptr_t null, const scoped_refptr<T>& rhs) {
|
||||||
|
return !operator==(null, rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) {
|
||||||
|
return out << p.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void swap(scoped_refptr<T>& lhs, scoped_refptr<T>& rhs) noexcept {
|
||||||
|
lhs.swap(rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_SCOPED_REFPTR_H_
|
||||||
190
include/base/cef_scoped_typeref_mac.h
Normal file
190
include/base/cef_scoped_typeref_mac.h
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
// Copyright (c) 2021 Marshall A. Greenblatt. Portions copyright (c) 2013
|
||||||
|
// Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_CEF_SCOPED_TYPEREF_MAC_H_
|
||||||
|
#define CEF_INCLUDE_BASE_CEF_SCOPED_TYPEREF_MAC_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
|
// When building CEF include the Chromium header directly.
|
||||||
|
#include "base/mac/scoped_typeref.h"
|
||||||
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
|
// The following is substantially similar to the Chromium implementation.
|
||||||
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
|
// updated to match.
|
||||||
|
|
||||||
|
#include "include/base/cef_logging.h"
|
||||||
|
#include "include/base/internal/cef_scoped_policy.h"
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct ScopedTypeRefTraits;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// ScopedTypeRef<> is patterned after std::unique_ptr<>, but maintains
|
||||||
|
/// ownership of a reference to any type that is maintained by Retain and
|
||||||
|
/// Release methods.
|
||||||
|
///
|
||||||
|
/// The Traits structure must provide the Retain and Release methods for type T.
|
||||||
|
/// A default ScopedTypeRefTraits is used but not defined, and should be defined
|
||||||
|
/// for each type to use this interface. For example, an appropriate definition
|
||||||
|
/// of ScopedTypeRefTraits for CGLContextObj would be:
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// template<>
|
||||||
|
/// struct ScopedTypeRefTraits<CGLContextObj> {
|
||||||
|
/// static CGLContextObj InvalidValue() { return nullptr; }
|
||||||
|
/// static CGLContextObj Retain(CGLContextObj object) {
|
||||||
|
/// CGLContextRetain(object);
|
||||||
|
/// return object;
|
||||||
|
/// }
|
||||||
|
/// static void Release(CGLContextObj object) { CGLContextRelease(object); }
|
||||||
|
/// };
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// For the many types that have pass-by-pointer create functions, the function
|
||||||
|
/// InitializeInto() is provided to allow direct initialization and assumption
|
||||||
|
/// of ownership of the object. For example, continuing to use the above
|
||||||
|
/// CGLContextObj specialization:
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// base::ScopedTypeRef<CGLContextObj> context;
|
||||||
|
/// CGLCreateContext(pixel_format, share_group, context.InitializeInto());
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// For initialization with an existing object, the caller may specify whether
|
||||||
|
/// the ScopedTypeRef<> being initialized is assuming the caller's existing
|
||||||
|
/// ownership of the object (and should not call Retain in initialization) or if
|
||||||
|
/// it should not assume this ownership and must create its own (by calling
|
||||||
|
/// Retain in initialization). This behavior is based on the |policy| parameter,
|
||||||
|
/// with |ASSUME| for the former and |RETAIN| for the latter. The default policy
|
||||||
|
/// is to |ASSUME|.
|
||||||
|
///
|
||||||
|
template <typename T, typename Traits = ScopedTypeRefTraits<T>>
|
||||||
|
class ScopedTypeRef {
|
||||||
|
public:
|
||||||
|
using element_type = T;
|
||||||
|
|
||||||
|
explicit constexpr ScopedTypeRef(
|
||||||
|
element_type object = Traits::InvalidValue(),
|
||||||
|
base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME)
|
||||||
|
: object_(object) {
|
||||||
|
if (object_ && policy == base::scoped_policy::RETAIN) {
|
||||||
|
object_ = Traits::Retain(object_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedTypeRef(const ScopedTypeRef<T, Traits>& that) : object_(that.object_) {
|
||||||
|
if (object_) {
|
||||||
|
object_ = Traits::Retain(object_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This allows passing an object to a function that takes its superclass.
|
||||||
|
template <typename R, typename RTraits>
|
||||||
|
explicit ScopedTypeRef(const ScopedTypeRef<R, RTraits>& that_as_subclass)
|
||||||
|
: object_(that_as_subclass.get()) {
|
||||||
|
if (object_) {
|
||||||
|
object_ = Traits::Retain(object_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedTypeRef(ScopedTypeRef<T, Traits>&& that) : object_(that.object_) {
|
||||||
|
that.object_ = Traits::InvalidValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
~ScopedTypeRef() {
|
||||||
|
if (object_) {
|
||||||
|
Traits::Release(object_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScopedTypeRef& operator=(const ScopedTypeRef<T, Traits>& that) {
|
||||||
|
reset(that.get(), base::scoped_policy::RETAIN);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is to be used only to take ownership of objects that are created
|
||||||
|
// by pass-by-pointer create functions. To enforce this, require that the
|
||||||
|
// object be reset to NULL before this may be used.
|
||||||
|
[[nodiscard]] element_type* InitializeInto() {
|
||||||
|
DCHECK(!object_);
|
||||||
|
return &object_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(const ScopedTypeRef<T, Traits>& that) {
|
||||||
|
reset(that.get(), base::scoped_policy::RETAIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset(element_type object = Traits::InvalidValue(),
|
||||||
|
base::scoped_policy::OwnershipPolicy policy =
|
||||||
|
base::scoped_policy::ASSUME) {
|
||||||
|
if (object && policy == base::scoped_policy::RETAIN) {
|
||||||
|
object = Traits::Retain(object);
|
||||||
|
}
|
||||||
|
if (object_) {
|
||||||
|
Traits::Release(object_);
|
||||||
|
}
|
||||||
|
object_ = object;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const element_type& that) const { return object_ == that; }
|
||||||
|
|
||||||
|
bool operator!=(const element_type& that) const { return object_ != that; }
|
||||||
|
|
||||||
|
operator element_type() const { return object_; }
|
||||||
|
|
||||||
|
element_type get() const { return object_; }
|
||||||
|
|
||||||
|
void swap(ScopedTypeRef& that) {
|
||||||
|
element_type temp = that.object_;
|
||||||
|
that.object_ = object_;
|
||||||
|
object_ = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScopedTypeRef<>::release() is like std::unique_ptr<>::release. It is NOT
|
||||||
|
// a wrapper for Release(). To force a ScopedTypeRef<> object to call
|
||||||
|
// Release(), use ScopedTypeRef<>::reset().
|
||||||
|
[[nodiscard]] element_type release() {
|
||||||
|
element_type temp = object_;
|
||||||
|
object_ = Traits::InvalidValue();
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
element_type object_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_CEF_SCOPED_TYPEREF_MAC_H_
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2013
|
|
||||||
// Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_STRING16_H_
|
|
||||||
#define CEF_INCLUDE_BASE_CEF_STRING16_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(BASE_STRINGS_STRING16_H_)
|
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
|
||||||
#include "base/strings/string16.h"
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
|
||||||
// The following is substantially similar to the Chromium implementation.
|
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
|
||||||
// updated to match.
|
|
||||||
// WHAT:
|
|
||||||
// A version of std::basic_string that provides 2-byte characters even when
|
|
||||||
// wchar_t is not implemented as a 2-byte type. You can access this class as
|
|
||||||
// string16. We also define char16, which string16 is based upon.
|
|
||||||
//
|
|
||||||
// WHY:
|
|
||||||
// On Windows, wchar_t is 2 bytes, and it can conveniently handle UTF-16/UCS-2
|
|
||||||
// data. Plenty of existing code operates on strings encoded as UTF-16.
|
|
||||||
//
|
|
||||||
// On many other platforms, sizeof(wchar_t) is 4 bytes by default. We can make
|
|
||||||
// it 2 bytes by using the GCC flag -fshort-wchar. But then std::wstring fails
|
|
||||||
// at run time, because it calls some functions (like wcslen) that come from
|
|
||||||
// the system's native C library -- which was built with a 4-byte wchar_t!
|
|
||||||
// It's wasteful to use 4-byte wchar_t strings to carry UTF-16 data, and it's
|
|
||||||
// entirely improper on those systems where the encoding of wchar_t is defined
|
|
||||||
// as UTF-32.
|
|
||||||
//
|
|
||||||
// Here, we define string16, which is similar to std::wstring but replaces all
|
|
||||||
// libc functions with custom, 2-byte-char compatible routines. It is capable
|
|
||||||
// of carrying UTF-16-encoded data.
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "include/base/cef_basictypes.h"
|
|
||||||
|
|
||||||
#if defined(WCHAR_T_IS_UTF16)
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
|
|
||||||
typedef wchar_t char16;
|
|
||||||
typedef std::wstring string16;
|
|
||||||
typedef std::char_traits<wchar_t> string16_char_traits;
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#elif defined(WCHAR_T_IS_UTF32)
|
|
||||||
|
|
||||||
#include <stdint.h> // For uint16_t
|
|
||||||
|
|
||||||
#include "include/base/cef_macros.h"
|
|
||||||
|
|
||||||
namespace cef {
|
|
||||||
namespace base {
|
|
||||||
|
|
||||||
typedef uint16_t char16;
|
|
||||||
|
|
||||||
// char16 versions of the functions required by string16_char_traits; these
|
|
||||||
// are based on the wide character functions of similar names ("w" or "wcs"
|
|
||||||
// instead of "c16").
|
|
||||||
int c16memcmp(const char16* s1, const char16* s2, size_t n);
|
|
||||||
size_t c16len(const char16* s);
|
|
||||||
const char16* c16memchr(const char16* s, char16 c, size_t n);
|
|
||||||
char16* c16memmove(char16* s1, const char16* s2, size_t n);
|
|
||||||
char16* c16memcpy(char16* s1, const char16* s2, size_t n);
|
|
||||||
char16* c16memset(char16* s, char16 c, size_t n);
|
|
||||||
|
|
||||||
struct string16_char_traits {
|
|
||||||
typedef char16 char_type;
|
|
||||||
typedef int int_type;
|
|
||||||
|
|
||||||
// int_type needs to be able to hold each possible value of char_type, and in
|
|
||||||
// addition, the distinct value of eof().
|
|
||||||
COMPILE_ASSERT(sizeof(int_type) > sizeof(char_type), unexpected_type_width);
|
|
||||||
|
|
||||||
typedef std::streamoff off_type;
|
|
||||||
typedef mbstate_t state_type;
|
|
||||||
typedef std::fpos<state_type> pos_type;
|
|
||||||
|
|
||||||
static void assign(char_type& c1, const char_type& c2) { c1 = c2; }
|
|
||||||
|
|
||||||
static bool eq(const char_type& c1, const char_type& c2) { return c1 == c2; }
|
|
||||||
static bool lt(const char_type& c1, const char_type& c2) { return c1 < c2; }
|
|
||||||
|
|
||||||
static int compare(const char_type* s1, const char_type* s2, size_t n) {
|
|
||||||
return c16memcmp(s1, s2, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t length(const char_type* s) { return c16len(s); }
|
|
||||||
|
|
||||||
static const char_type* find(const char_type* s,
|
|
||||||
size_t n,
|
|
||||||
const char_type& a) {
|
|
||||||
return c16memchr(s, a, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char_type* move(char_type* s1, const char_type* s2, int_type n) {
|
|
||||||
return c16memmove(s1, s2, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char_type* copy(char_type* s1, const char_type* s2, size_t n) {
|
|
||||||
return c16memcpy(s1, s2, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char_type* assign(char_type* s, size_t n, char_type a) {
|
|
||||||
return c16memset(s, a, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int_type not_eof(const int_type& c) {
|
|
||||||
return eq_int_type(c, eof()) ? 0 : c;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char_type to_char_type(const int_type& c) { return char_type(c); }
|
|
||||||
|
|
||||||
static int_type to_int_type(const char_type& c) { return int_type(c); }
|
|
||||||
|
|
||||||
static bool eq_int_type(const int_type& c1, const int_type& c2) {
|
|
||||||
return c1 == c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int_type eof() { return static_cast<int_type>(EOF); }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::basic_string<char16, string16_char_traits> string16;
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
} // namespace cef
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
|
|
||||||
typedef cef::base::char16 char16;
|
|
||||||
typedef cef::base::string16 string16;
|
|
||||||
|
|
||||||
extern std::ostream& operator<<(std::ostream& out, const string16& str);
|
|
||||||
|
|
||||||
// This is required by googletest to print a readable output on test failures.
|
|
||||||
extern void PrintTo(const string16& str, std::ostream* out);
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
// The string class will be explicitly instantiated only once, in string16.cc.
|
|
||||||
//
|
|
||||||
// std::basic_string<> in GNU libstdc++ contains a static data member,
|
|
||||||
// _S_empty_rep_storage, to represent empty strings. When an operation such
|
|
||||||
// as assignment or destruction is performed on a string, causing its existing
|
|
||||||
// data member to be invalidated, it must not be freed if this static data
|
|
||||||
// member is being used. Otherwise, it counts as an attempt to free static
|
|
||||||
// (and not allocated) data, which is a memory error.
|
|
||||||
//
|
|
||||||
// Generally, due to C++ template magic, _S_empty_rep_storage will be marked
|
|
||||||
// as a coalesced symbol, meaning that the linker will combine multiple
|
|
||||||
// instances into a single one when generating output.
|
|
||||||
//
|
|
||||||
// If a string class is used by multiple shared libraries, a problem occurs.
|
|
||||||
// Each library will get its own copy of _S_empty_rep_storage. When strings
|
|
||||||
// are passed across a library boundary for alteration or destruction, memory
|
|
||||||
// errors will result. GNU libstdc++ contains a configuration option,
|
|
||||||
// --enable-fully-dynamic-string (_GLIBCXX_FULLY_DYNAMIC_STRING), which
|
|
||||||
// disables the static data member optimization, but it's a good optimization
|
|
||||||
// and non-STL code is generally at the mercy of the system's STL
|
|
||||||
// configuration. Fully-dynamic strings are not the default for GNU libstdc++
|
|
||||||
// libstdc++ itself or for the libstdc++ installations on the systems we care
|
|
||||||
// about, such as Mac OS X and relevant flavors of Linux.
|
|
||||||
//
|
|
||||||
// See also http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24196 .
|
|
||||||
//
|
|
||||||
// To avoid problems, string classes need to be explicitly instantiated only
|
|
||||||
// once, in exactly one library. All other string users see it via an "extern"
|
|
||||||
// declaration. This is precisely how GNU libstdc++ handles
|
|
||||||
// std::basic_string<char> (string) and std::basic_string<wchar_t> (wstring).
|
|
||||||
//
|
|
||||||
// This also works around a Mac OS X linker bug in ld64-85.2.1 (Xcode 3.1.2),
|
|
||||||
// in which the linker does not fully coalesce symbols when dead code
|
|
||||||
// stripping is enabled. This bug causes the memory errors described above
|
|
||||||
// to occur even when a std::basic_string<> does not cross shared library
|
|
||||||
// boundaries, such as in statically-linked executables.
|
|
||||||
//
|
|
||||||
// TODO(mark): File this bug with Apple and update this note with a bug number.
|
|
||||||
|
|
||||||
extern template class std::basic_string<cef::base::char16,
|
|
||||||
cef::base::string16_char_traits>;
|
|
||||||
|
|
||||||
#endif // WCHAR_T_IS_UTF32
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_STRING16_H_
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011
|
|
||||||
// Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
|
||||||
#define CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(BASE_TEMPLATE_UTIL_H_)
|
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
|
||||||
#include "base/template_util.h"
|
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
|
||||||
// The following is substantially similar to the Chromium implementation.
|
|
||||||
// If the Chromium implementation diverges the below implementation should be
|
|
||||||
// updated to match.
|
|
||||||
|
|
||||||
#include <cstddef> // For size_t.
|
|
||||||
|
|
||||||
#include "include/base/cef_build.h"
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
|
|
||||||
// template definitions from tr1
|
|
||||||
|
|
||||||
template <class T, T v>
|
|
||||||
struct integral_constant {
|
|
||||||
static const T value = v;
|
|
||||||
typedef T value_type;
|
|
||||||
typedef integral_constant<T, v> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T, T v>
|
|
||||||
const T integral_constant<T, v>::value;
|
|
||||||
|
|
||||||
typedef integral_constant<bool, true> true_type;
|
|
||||||
typedef integral_constant<bool, false> false_type;
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct is_pointer : false_type {};
|
|
||||||
template <class T>
|
|
||||||
struct is_pointer<T*> : true_type {};
|
|
||||||
|
|
||||||
// Member function pointer detection up to four params. Add more as needed
|
|
||||||
// below. This is built-in to C++ 11, and we can remove this when we switch.
|
|
||||||
template <typename T>
|
|
||||||
struct is_member_function_pointer : false_type {};
|
|
||||||
|
|
||||||
template <typename R, typename Z>
|
|
||||||
struct is_member_function_pointer<R (Z::*)()> : true_type {};
|
|
||||||
template <typename R, typename Z>
|
|
||||||
struct is_member_function_pointer<R (Z::*)() const> : true_type {};
|
|
||||||
|
|
||||||
template <typename R, typename Z, typename A>
|
|
||||||
struct is_member_function_pointer<R (Z::*)(A)> : true_type {};
|
|
||||||
template <typename R, typename Z, typename A>
|
|
||||||
struct is_member_function_pointer<R (Z::*)(A) const> : true_type {};
|
|
||||||
|
|
||||||
template <typename R, typename Z, typename A, typename B>
|
|
||||||
struct is_member_function_pointer<R (Z::*)(A, B)> : true_type {};
|
|
||||||
template <typename R, typename Z, typename A, typename B>
|
|
||||||
struct is_member_function_pointer<R (Z::*)(A, B) const> : true_type {};
|
|
||||||
|
|
||||||
template <typename R, typename Z, typename A, typename B, typename C>
|
|
||||||
struct is_member_function_pointer<R (Z::*)(A, B, C)> : true_type {};
|
|
||||||
template <typename R, typename Z, typename A, typename B, typename C>
|
|
||||||
struct is_member_function_pointer<R (Z::*)(A, B, C) const> : true_type {};
|
|
||||||
|
|
||||||
template <typename R,
|
|
||||||
typename Z,
|
|
||||||
typename A,
|
|
||||||
typename B,
|
|
||||||
typename C,
|
|
||||||
typename D>
|
|
||||||
struct is_member_function_pointer<R (Z::*)(A, B, C, D)> : true_type {};
|
|
||||||
template <typename R,
|
|
||||||
typename Z,
|
|
||||||
typename A,
|
|
||||||
typename B,
|
|
||||||
typename C,
|
|
||||||
typename D>
|
|
||||||
struct is_member_function_pointer<R (Z::*)(A, B, C, D) const> : true_type {};
|
|
||||||
|
|
||||||
template <class T, class U>
|
|
||||||
struct is_same : public false_type {};
|
|
||||||
template <class T>
|
|
||||||
struct is_same<T, T> : true_type {};
|
|
||||||
|
|
||||||
template <class>
|
|
||||||
struct is_array : public false_type {};
|
|
||||||
template <class T, size_t n>
|
|
||||||
struct is_array<T[n]> : public true_type {};
|
|
||||||
template <class T>
|
|
||||||
struct is_array<T[]> : public true_type {};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct is_non_const_reference : false_type {};
|
|
||||||
template <class T>
|
|
||||||
struct is_non_const_reference<T&> : true_type {};
|
|
||||||
template <class T>
|
|
||||||
struct is_non_const_reference<const T&> : false_type {};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct is_const : false_type {};
|
|
||||||
template <class T>
|
|
||||||
struct is_const<const T> : true_type {};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct is_void : false_type {};
|
|
||||||
template <>
|
|
||||||
struct is_void<void> : true_type {};
|
|
||||||
|
|
||||||
namespace cef_internal {
|
|
||||||
|
|
||||||
// Types YesType and NoType are guaranteed such that sizeof(YesType) <
|
|
||||||
// sizeof(NoType).
|
|
||||||
typedef char YesType;
|
|
||||||
|
|
||||||
struct NoType {
|
|
||||||
YesType dummy[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
// This class is an implementation detail for is_convertible, and you
|
|
||||||
// don't need to know how it works to use is_convertible. For those
|
|
||||||
// who care: we declare two different functions, one whose argument is
|
|
||||||
// of type To and one with a variadic argument list. We give them
|
|
||||||
// return types of different size, so we can use sizeof to trick the
|
|
||||||
// compiler into telling us which function it would have chosen if we
|
|
||||||
// had called it with an argument of type From. See Alexandrescu's
|
|
||||||
// _Modern C++ Design_ for more details on this sort of trick.
|
|
||||||
|
|
||||||
struct ConvertHelper {
|
|
||||||
template <typename To>
|
|
||||||
static YesType Test(To);
|
|
||||||
|
|
||||||
template <typename To>
|
|
||||||
static NoType Test(...);
|
|
||||||
|
|
||||||
template <typename From>
|
|
||||||
static From& Create();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Used to determine if a type is a struct/union/class. Inspired by Boost's
|
|
||||||
// is_class type_trait implementation.
|
|
||||||
struct IsClassHelper {
|
|
||||||
template <typename C>
|
|
||||||
static YesType Test(void (C::*)(void));
|
|
||||||
|
|
||||||
template <typename C>
|
|
||||||
static NoType Test(...);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace cef_internal
|
|
||||||
|
|
||||||
// Inherits from true_type if From is convertible to To, false_type otherwise.
|
|
||||||
//
|
|
||||||
// Note that if the type is convertible, this will be a true_type REGARDLESS
|
|
||||||
// of whether or not the conversion would emit a warning.
|
|
||||||
template <typename From, typename To>
|
|
||||||
struct is_convertible
|
|
||||||
: integral_constant<bool,
|
|
||||||
sizeof(cef_internal::ConvertHelper::Test<To>(
|
|
||||||
cef_internal::ConvertHelper::Create<From>())) ==
|
|
||||||
sizeof(cef_internal::YesType)> {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct is_class
|
|
||||||
: integral_constant<bool,
|
|
||||||
sizeof(cef_internal::IsClassHelper::Test<T>(0)) ==
|
|
||||||
sizeof(cef_internal::YesType)> {};
|
|
||||||
|
|
||||||
template <bool B, class T = void>
|
|
||||||
struct enable_if {};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct enable_if<true, T> {
|
|
||||||
typedef T type;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_
|
|
||||||
@@ -32,12 +32,7 @@
|
|||||||
#define CEF_INCLUDE_BASE_THREAD_CHECKER_H_
|
#define CEF_INCLUDE_BASE_THREAD_CHECKER_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_THREADING_THREAD_CHECKER_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/threading/thread_checker.h"
|
#include "base/threading/thread_checker.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -48,10 +43,12 @@
|
|||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/internal/cef_thread_checker_impl.h"
|
#include "include/base/internal/cef_thread_checker_impl.h"
|
||||||
|
|
||||||
// Apart from debug builds, we also enable the thread checker in
|
///
|
||||||
// builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots
|
/// Apart from debug builds, we also enable the thread checker in
|
||||||
// with this define will get the same level of thread checking as
|
/// builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots
|
||||||
// debug bots.
|
/// with this define will get the same level of thread checking as
|
||||||
|
/// debug bots.
|
||||||
|
///
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
#define ENABLE_THREAD_CHECKER 1
|
#define ENABLE_THREAD_CHECKER 1
|
||||||
#else
|
#else
|
||||||
@@ -62,10 +59,12 @@ namespace base {
|
|||||||
|
|
||||||
namespace cef_internal {
|
namespace cef_internal {
|
||||||
|
|
||||||
// Do nothing implementation, for use in release mode.
|
///
|
||||||
//
|
/// Do nothing implementation, for use in release mode.
|
||||||
// Note: You should almost always use the ThreadChecker class to get the
|
///
|
||||||
// right version for your build configuration.
|
/// Note: You should almost always use the ThreadChecker class to get the
|
||||||
|
/// right version for your build configuration.
|
||||||
|
///
|
||||||
class ThreadCheckerDoNothing {
|
class ThreadCheckerDoNothing {
|
||||||
public:
|
public:
|
||||||
bool CalledOnValidThread() const { return true; }
|
bool CalledOnValidThread() const { return true; }
|
||||||
@@ -75,37 +74,42 @@ class ThreadCheckerDoNothing {
|
|||||||
|
|
||||||
} // namespace cef_internal
|
} // namespace cef_internal
|
||||||
|
|
||||||
// ThreadChecker is a helper class used to help verify that some methods of a
|
///
|
||||||
// class are called from the same thread. It provides identical functionality to
|
/// ThreadChecker is a helper class used to help verify that some methods of a
|
||||||
// base::NonThreadSafe, but it is meant to be held as a member variable, rather
|
/// class are called from the same thread. It provides identical functionality
|
||||||
// than inherited from base::NonThreadSafe.
|
/// to base::NonThreadSafe, but it is meant to be held as a member variable,
|
||||||
//
|
/// rather than inherited from base::NonThreadSafe.
|
||||||
// While inheriting from base::NonThreadSafe may give a clear indication about
|
///
|
||||||
// the thread-safety of a class, it may also lead to violations of the style
|
/// While inheriting from base::NonThreadSafe may give a clear indication about
|
||||||
// guide with regard to multiple inheritance. The choice between having a
|
/// the thread-safety of a class, it may also lead to violations of the style
|
||||||
// ThreadChecker member and inheriting from base::NonThreadSafe should be based
|
/// guide with regard to multiple inheritance. The choice between having a
|
||||||
// on whether:
|
/// ThreadChecker member and inheriting from base::NonThreadSafe should be based
|
||||||
// - Derived classes need to know the thread they belong to, as opposed to
|
/// on whether:
|
||||||
// having that functionality fully encapsulated in the base class.
|
/// - Derived classes need to know the thread they belong to, as opposed to
|
||||||
// - Derived classes should be able to reassign the base class to another
|
/// having that functionality fully encapsulated in the base class.
|
||||||
// thread, via DetachFromThread.
|
/// - Derived classes should be able to reassign the base class to another
|
||||||
//
|
/// thread, via DetachFromThread.
|
||||||
// If neither of these are true, then having a ThreadChecker member and calling
|
///
|
||||||
// CalledOnValidThread is the preferable solution.
|
/// If neither of these are true, then having a ThreadChecker member and calling
|
||||||
//
|
/// CalledOnValidThread is the preferable solution.
|
||||||
// Example:
|
///
|
||||||
// class MyClass {
|
/// Example:
|
||||||
// public:
|
///
|
||||||
// void Foo() {
|
/// <pre>
|
||||||
// DCHECK(thread_checker_.CalledOnValidThread());
|
/// class MyClass {
|
||||||
// ... (do stuff) ...
|
/// public:
|
||||||
// }
|
/// void Foo() {
|
||||||
//
|
/// DCHECK(thread_checker_.CalledOnValidThread());
|
||||||
// private:
|
/// ... (do stuff) ...
|
||||||
// ThreadChecker thread_checker_;
|
/// }
|
||||||
// }
|
///
|
||||||
//
|
/// private:
|
||||||
// In Release mode, CalledOnValidThread will always return true.
|
/// ThreadChecker thread_checker_;
|
||||||
|
/// }
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// In Release mode, CalledOnValidThread will always return true.
|
||||||
|
///
|
||||||
#if ENABLE_THREAD_CHECKER
|
#if ENABLE_THREAD_CHECKER
|
||||||
class ThreadChecker : public cef_internal::ThreadCheckerImpl {};
|
class ThreadChecker : public cef_internal::ThreadCheckerImpl {};
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -29,124 +29,133 @@
|
|||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
///
|
///
|
||||||
// Trace events are for tracking application performance and resource usage.
|
/// \file
|
||||||
// Macros are provided to track:
|
/// Trace events are for tracking application performance and resource usage.
|
||||||
// Begin and end of function calls
|
/// Macros are provided to track:
|
||||||
// Counters
|
/// Begin and end of function calls
|
||||||
//
|
/// Counters
|
||||||
// Events are issued against categories. Whereas LOG's categories are statically
|
///
|
||||||
// defined, TRACE categories are created implicitly with a string. For example:
|
/// Events are issued against categories. Whereas LOG's categories are
|
||||||
// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
|
/// statically defined, TRACE categories are created implicitly with a string.
|
||||||
//
|
/// For example: <pre>
|
||||||
// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
|
/// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
|
||||||
// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
|
/// </pre>
|
||||||
// doSomethingCostly()
|
///
|
||||||
// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
|
/// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
|
||||||
// Note: Our tools can't always determine the correct BEGIN/END pairs unless
|
/// <pre>
|
||||||
// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
|
/// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
|
||||||
// need them to be in separate scopes.
|
/// doSomethingCostly()
|
||||||
//
|
/// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
|
||||||
// A common use case is to trace entire function scopes. This issues a trace
|
/// </pre>
|
||||||
// BEGIN and END automatically:
|
/// Note: Our tools can't always determine the correct BEGIN/END pairs unless
|
||||||
// void doSomethingCostly() {
|
/// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
|
||||||
// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
|
/// need them to be in separate scopes.
|
||||||
// ...
|
///
|
||||||
// }
|
/// A common use case is to trace entire function scopes. This issues a trace
|
||||||
//
|
/// BEGIN and END automatically:
|
||||||
// Additional parameters can be associated with an event:
|
/// <pre>
|
||||||
// void doSomethingCostly2(int howMuch) {
|
/// void doSomethingCostly() {
|
||||||
// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
|
/// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
|
||||||
// "howMuch", howMuch);
|
/// ...
|
||||||
// ...
|
/// }
|
||||||
// }
|
/// </pre>
|
||||||
//
|
///
|
||||||
// The trace system will automatically add to this information the current
|
/// Additional parameters can be associated with an event:
|
||||||
// process id, thread id, and a timestamp in microseconds.
|
/// <pre>
|
||||||
//
|
/// void doSomethingCostly2(int howMuch) {
|
||||||
// To trace an asynchronous procedure such as an IPC send/receive, use
|
/// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
|
||||||
// ASYNC_BEGIN and ASYNC_END:
|
/// "howMuch", howMuch);
|
||||||
// [single threaded sender code]
|
/// ...
|
||||||
// static int send_count = 0;
|
/// }
|
||||||
// ++send_count;
|
/// </pre>
|
||||||
// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
|
///
|
||||||
// Send(new MyMessage(send_count));
|
/// The trace system will automatically add to this information the current
|
||||||
// [receive code]
|
/// process id, thread id, and a timestamp in microseconds.
|
||||||
// void OnMyMessage(send_count) {
|
///
|
||||||
// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
|
/// To trace an asynchronous procedure such as an IPC send/receive, use
|
||||||
// }
|
/// ASYNC_BEGIN and ASYNC_END:
|
||||||
// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
|
/// <pre>
|
||||||
// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
|
/// [single threaded sender code]
|
||||||
// Pointers can be used for the ID parameter, and they will be mangled
|
/// static int send_count = 0;
|
||||||
// internally so that the same pointer on two different processes will not
|
/// ++send_count;
|
||||||
// match. For example:
|
/// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
|
||||||
// class MyTracedClass {
|
/// Send(new MyMessage(send_count));
|
||||||
// public:
|
/// [receive code]
|
||||||
// MyTracedClass() {
|
/// void OnMyMessage(send_count) {
|
||||||
// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
|
/// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
|
||||||
// }
|
/// }
|
||||||
// ~MyTracedClass() {
|
/// </pre>
|
||||||
// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
|
/// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
|
||||||
// }
|
/// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
|
||||||
// }
|
/// Pointers can be used for the ID parameter, and they will be mangled
|
||||||
//
|
/// internally so that the same pointer on two different processes will not
|
||||||
// The trace event also supports counters, which is a way to track a quantity
|
/// match. For example:
|
||||||
// as it varies over time. Counters are created with the following macro:
|
/// <pre>
|
||||||
// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
|
/// class MyTracedClass {
|
||||||
//
|
/// public:
|
||||||
// Counters are process-specific. The macro itself can be issued from any
|
/// MyTracedClass() {
|
||||||
// thread, however.
|
/// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
|
||||||
//
|
/// }
|
||||||
// Sometimes, you want to track two counters at once. You can do this with two
|
/// ~MyTracedClass() {
|
||||||
// counter macros:
|
/// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
|
||||||
// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
|
/// }
|
||||||
// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
|
/// }
|
||||||
// Or you can do it with a combined macro:
|
/// </pre>
|
||||||
// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
|
///
|
||||||
// "bytesPinned", g_myCounterValue[0],
|
/// The trace event also supports counters, which is a way to track a quantity
|
||||||
// "bytesAllocated", g_myCounterValue[1]);
|
/// as it varies over time. Counters are created with the following macro:
|
||||||
// This indicates to the tracing UI that these counters should be displayed
|
/// <pre>
|
||||||
// in a single graph, as a summed area chart.
|
/// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
|
||||||
//
|
/// </pre>
|
||||||
// Since counters are in a global namespace, you may want to disembiguate with a
|
///
|
||||||
// unique ID, by using the TRACE_COUNTER_ID* variations.
|
/// Counters are process-specific. The macro itself can be issued from any
|
||||||
//
|
/// thread, however.
|
||||||
// By default, trace collection is compiled in, but turned off at runtime.
|
///
|
||||||
// Collecting trace data is the responsibility of the embedding application. In
|
/// Sometimes, you want to track two counters at once. You can do this with two
|
||||||
// CEF's case, calling BeginTracing will turn on tracing on all active
|
/// counter macros:
|
||||||
// processes.
|
/// <pre>
|
||||||
//
|
/// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
|
||||||
//
|
/// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
|
||||||
// Memory scoping note:
|
/// </pre>
|
||||||
// Tracing copies the pointers, not the string content, of the strings passed
|
/// Or you can do it with a combined macro:
|
||||||
// in for category, name, and arg_names. Thus, the following code will cause
|
/// <pre>
|
||||||
// problems:
|
/// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
|
||||||
// char* str = strdup("impprtantName");
|
/// "bytesPinned", g_myCounterValue[0],
|
||||||
// TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD!
|
/// "bytesAllocated", g_myCounterValue[1]);
|
||||||
// free(str); // Trace system now has dangling pointer
|
/// </pre>
|
||||||
//
|
/// This indicates to the tracing UI that these counters should be displayed
|
||||||
// To avoid this issue with the |name| and |arg_name| parameters, use the
|
/// in a single graph, as a summed area chart.
|
||||||
// TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime
|
///
|
||||||
// overhead.
|
/// Since counters are in a global namespace, you may want to disembiguate with
|
||||||
// Notes: The category must always be in a long-lived char* (i.e. static const).
|
/// a unique ID, by using the TRACE_COUNTER_ID* variations.
|
||||||
// The |arg_values|, when used, are always deep copied with the _COPY
|
///
|
||||||
// macros.
|
/// By default, trace collection is compiled in, but turned off at runtime.
|
||||||
//
|
/// Collecting trace data is the responsibility of the embedding application. In
|
||||||
//
|
/// CEF's case, calling BeginTracing will turn on tracing on all active
|
||||||
// Thread Safety:
|
/// processes.
|
||||||
// All macros are thread safe and can be used from any process.
|
///
|
||||||
|
///
|
||||||
|
/// Memory scoping note:
|
||||||
|
/// Tracing copies the pointers, not the string content, of the strings passed
|
||||||
|
/// in for category, name, and arg_names. Thus, the following code will cause
|
||||||
|
/// problems:
|
||||||
|
/// <pre>
|
||||||
|
/// char* str = strdup("impprtantName");
|
||||||
|
/// TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD!
|
||||||
|
/// free(str); // Trace system now has dangling pointer
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// Thread Safety:
|
||||||
|
/// All macros are thread safe and can be used from any process.
|
||||||
///
|
///
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
#define CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(TRACE_EVENT0)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the macros provided by this header already exist.
|
/// When building CEF include the Chromium header directly.
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
|
||||||
#include "base/trace_event/trace_event.h"
|
#include "base/trace_event/trace_event.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
// The following is substantially similar to the Chromium implementation.
|
// The following is substantially similar to the Chromium implementation.
|
||||||
@@ -155,20 +164,22 @@
|
|||||||
|
|
||||||
#include "include/internal/cef_trace_event_internal.h"
|
#include "include/internal/cef_trace_event_internal.h"
|
||||||
|
|
||||||
// Records a pair of begin and end events called "name" for the current
|
///
|
||||||
// scope, with 0, 1 or 2 associated arguments. If the category is not
|
/// Records a pair of begin and end events called "name" for the current
|
||||||
// enabled, then this does nothing.
|
/// scope, with 0, 1 or 2 associated arguments. If the category is not
|
||||||
// - category and name strings must have application lifetime (statics or
|
/// enabled, then this does nothing.
|
||||||
// literals). They may not include " chars.
|
/// - category and name strings must have application lifetime (statics or
|
||||||
#define TRACE_EVENT0(category, name) \
|
/// literals). They may not include " chars.
|
||||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false); \
|
///
|
||||||
|
#define TRACE_EVENT0(category, name) \
|
||||||
|
cef_trace_event_begin(category, name, NULL, 0, NULL, 0); \
|
||||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||||
#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
|
#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false); \
|
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0); \
|
||||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||||
#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
|
#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val, false); \
|
arg2_val); \
|
||||||
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
|
||||||
|
|
||||||
// Implementation detail: trace event macros create temporary variable names.
|
// Implementation detail: trace event macros create temporary variable names.
|
||||||
@@ -184,228 +195,181 @@
|
|||||||
cef_trace_event::CefTraceEndOnScopeClose CEF_INTERNAL_TRACE_EVENT_UID( \
|
cef_trace_event::CefTraceEndOnScopeClose CEF_INTERNAL_TRACE_EVENT_UID( \
|
||||||
profileScope)(category, name)
|
profileScope)(category, name)
|
||||||
|
|
||||||
// Records a single event called "name" immediately, with 0, 1 or 2
|
///
|
||||||
// associated arguments. If the category is not enabled, then this
|
/// Records a single event called "name" immediately, with 0, 1 or 2
|
||||||
// does nothing.
|
/// associated arguments. If the category is not enabled, then this
|
||||||
// - category and name strings must have application lifetime (statics or
|
/// does nothing.
|
||||||
// literals). They may not include " chars.
|
/// - category and name strings must have application lifetime (statics or
|
||||||
|
/// literals). They may not include " chars.
|
||||||
|
///
|
||||||
#define TRACE_EVENT_INSTANT0(category, name) \
|
#define TRACE_EVENT_INSTANT0(category, name) \
|
||||||
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false)
|
cef_trace_event_instant(category, name, NULL, 0, NULL, 0)
|
||||||
#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
|
#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
|
||||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, false)
|
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0)
|
||||||
#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, arg2_name, \
|
#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val) \
|
arg2_val) \
|
||||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
|
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val, false)
|
arg2_val)
|
||||||
#define TRACE_EVENT_COPY_INSTANT0(category, name) \
|
|
||||||
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \
|
|
||||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \
|
|
||||||
arg2_name, arg2_val) \
|
|
||||||
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
|
|
||||||
arg2_val, true)
|
|
||||||
|
|
||||||
// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
|
///
|
||||||
// associated arguments. If the category is not enabled, then this
|
/// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
|
||||||
// does nothing.
|
/// associated arguments. If the category is not enabled, then this
|
||||||
// - category and name strings must have application lifetime (statics or
|
/// does nothing.
|
||||||
// literals). They may not include " chars.
|
/// - category and name strings must have application lifetime (statics or
|
||||||
|
/// literals). They may not include " chars.
|
||||||
|
///
|
||||||
#define TRACE_EVENT_BEGIN0(category, name) \
|
#define TRACE_EVENT_BEGIN0(category, name) \
|
||||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false)
|
cef_trace_event_begin(category, name, NULL, 0, NULL, 0)
|
||||||
#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
|
#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false)
|
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0)
|
||||||
#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
|
#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val) \
|
arg2_val) \
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val, false)
|
arg2_val)
|
||||||
#define TRACE_EVENT_COPY_BEGIN0(category, name) \
|
|
||||||
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \
|
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \
|
|
||||||
arg2_name, arg2_val) \
|
|
||||||
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
|
|
||||||
arg2_val, true)
|
|
||||||
|
|
||||||
// Records a single END event for "name" immediately. If the category
|
///
|
||||||
// is not enabled, then this does nothing.
|
/// Records a single END event for "name" immediately. If the category
|
||||||
// - category and name strings must have application lifetime (statics or
|
/// is not enabled, then this does nothing.
|
||||||
// literals). They may not include " chars.
|
/// - category and name strings must have application lifetime (statics or
|
||||||
|
/// literals). They may not include " chars.
|
||||||
|
///
|
||||||
#define TRACE_EVENT_END0(category, name) \
|
#define TRACE_EVENT_END0(category, name) \
|
||||||
cef_trace_event_end(category, name, NULL, 0, NULL, 0, false)
|
cef_trace_event_end(category, name, NULL, 0, NULL, 0)
|
||||||
#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
|
#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
|
||||||
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, false)
|
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0)
|
||||||
#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
|
#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
|
||||||
arg2_val) \
|
arg2_val) \
|
||||||
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, arg2_val)
|
||||||
arg2_val, false)
|
|
||||||
#define TRACE_EVENT_COPY_END0(category, name) \
|
|
||||||
cef_trace_event_end(category, name, NULL, 0, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \
|
|
||||||
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, arg2_name, \
|
|
||||||
arg2_val) \
|
|
||||||
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
|
|
||||||
arg2_val, true)
|
|
||||||
|
|
||||||
// Records the value of a counter called "name" immediately. Value
|
///
|
||||||
// must be representable as a 32 bit integer.
|
/// Records the value of a counter called "name" immediately. Value
|
||||||
// - category and name strings must have application lifetime (statics or
|
/// must be representable as a 32 bit integer.
|
||||||
// literals). They may not include " chars.
|
/// - category and name strings must have application lifetime (statics or
|
||||||
|
/// literals). They may not include " chars.
|
||||||
|
///
|
||||||
#define TRACE_COUNTER1(category, name, value) \
|
#define TRACE_COUNTER1(category, name, value) \
|
||||||
cef_trace_counter(category, name, NULL, value, NULL, 0, false)
|
cef_trace_counter(category, name, NULL, value, NULL, 0)
|
||||||
#define TRACE_COPY_COUNTER1(category, name, value) \
|
|
||||||
cef_trace_counter(category, name, NULL, value, NULL, 0, true)
|
|
||||||
|
|
||||||
// Records the values of a multi-parted counter called "name" immediately.
|
///
|
||||||
// The UI will treat value1 and value2 as parts of a whole, displaying their
|
/// Records the values of a multi-parted counter called "name" immediately.
|
||||||
// values as a stacked-bar chart.
|
/// The UI will treat value1 and value2 as parts of a whole, displaying their
|
||||||
// - category and name strings must have application lifetime (statics or
|
/// values as a stacked-bar chart.
|
||||||
// literals). They may not include " chars.
|
/// - category and name strings must have application lifetime (statics or
|
||||||
|
/// literals). They may not include " chars.
|
||||||
|
///
|
||||||
#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
|
#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
|
||||||
value2_val) \
|
value2_val) \
|
||||||
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
|
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
|
||||||
value2_val, false)
|
value2_val)
|
||||||
#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \
|
|
||||||
value2_name, value2_val) \
|
|
||||||
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
|
|
||||||
value2_val, true)
|
|
||||||
|
|
||||||
// Records the value of a counter called "name" immediately. Value
|
///
|
||||||
// must be representable as a 32 bit integer.
|
/// Records the value of a counter called "name" immediately. Value
|
||||||
// - category and name strings must have application lifetime (statics or
|
/// must be representable as a 32 bit integer.
|
||||||
// literals). They may not include " chars.
|
/// - category and name strings must have application lifetime (statics or
|
||||||
// - |id| is used to disambiguate counters with the same name. It must either
|
/// literals). They may not include " chars.
|
||||||
// be a pointer or an integer value up to 64 bits. If it's a pointer, the
|
/// - |id| is used to disambiguate counters with the same name. It must either
|
||||||
// bits will be xored with a hash of the process ID so that the same pointer
|
/// be a pointer or an integer value up to 64 bits. If it's a pointer, the
|
||||||
// on two different processes will not collide.
|
/// bits will be xored with a hash of the process ID so that the same pointer
|
||||||
|
/// on two different processes will not collide.
|
||||||
|
///
|
||||||
#define TRACE_COUNTER_ID1(category, name, id, value) \
|
#define TRACE_COUNTER_ID1(category, name, id, value) \
|
||||||
cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, false)
|
cef_trace_counter_id(category, name, id, NULL, value, NULL, 0)
|
||||||
#define TRACE_COPY_COUNTER_ID1(category, name, id, value) \
|
|
||||||
cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, true)
|
|
||||||
|
|
||||||
// Records the values of a multi-parted counter called "name" immediately.
|
///
|
||||||
// The UI will treat value1 and value2 as parts of a whole, displaying their
|
/// Records the values of a multi-parted counter called "name" immediately.
|
||||||
// values as a stacked-bar chart.
|
/// The UI will treat value1 and value2 as parts of a whole, displaying their
|
||||||
// - category and name strings must have application lifetime (statics or
|
/// values as a stacked-bar chart.
|
||||||
// literals). They may not include " chars.
|
/// - category and name strings must have application lifetime (statics or
|
||||||
// - |id| is used to disambiguate counters with the same name. It must either
|
/// literals). They may not include " chars.
|
||||||
// be a pointer or an integer value up to 64 bits. If it's a pointer, the
|
/// - |id| is used to disambiguate counters with the same name. It must either
|
||||||
// bits will be xored with a hash of the process ID so that the same pointer
|
/// be a pointer or an integer value up to 64 bits. If it's a pointer, the
|
||||||
// on two different processes will not collide.
|
/// bits will be xored with a hash of the process ID so that the same pointer
|
||||||
|
/// on two different processes will not collide.
|
||||||
|
///
|
||||||
#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
|
#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
|
||||||
value2_name, value2_val) \
|
value2_name, value2_val) \
|
||||||
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
||||||
value2_name, value2_val, false)
|
value2_name, value2_val)
|
||||||
#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \
|
|
||||||
value2_name, value2_val) \
|
|
||||||
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
|
|
||||||
value2_name, value2_val, true)
|
|
||||||
|
|
||||||
// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
|
///
|
||||||
// associated arguments. If the category is not enabled, then this
|
/// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
|
||||||
// does nothing.
|
/// associated arguments. If the category is not enabled, then this
|
||||||
// - category and name strings must have application lifetime (statics or
|
/// does nothing.
|
||||||
// literals). They may not include " chars.
|
/// - category and name strings must have application lifetime (statics or
|
||||||
// - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event.
|
/// literals). They may not include " chars.
|
||||||
// ASYNC events are considered to match if their category, name and id values
|
/// - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event.
|
||||||
// all match. |id| must either be a pointer or an integer value up to 64
|
/// ASYNC events are considered to match if their category, name and id values
|
||||||
// bits. If it's a pointer, the bits will be xored with a hash of the process
|
/// all match. |id| must either be a pointer or an integer value up to 64
|
||||||
// ID sothat the same pointer on two different processes will not collide.
|
/// bits. If it's a pointer, the bits will be xored with a hash of the process
|
||||||
// An asynchronous operation can consist of multiple phases. The first phase is
|
/// ID sothat the same pointer on two different processes will not collide.
|
||||||
// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
|
/// An asynchronous operation can consist of multiple phases. The first phase is
|
||||||
// ASYNC_STEP_BEGIN macros. When the operation completes, call ASYNC_END.
|
/// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
|
||||||
// An async operation can span threads and processes, but all events in that
|
/// ASYNC_STEP_BEGIN macros. When the operation completes, call ASYNC_END.
|
||||||
// operation must use the same |name| and |id|. Each event can have its own
|
/// An async operation can span threads and processes, but all events in that
|
||||||
// args.
|
/// operation must use the same |name| and |id|. Each event can have its own
|
||||||
|
/// args.
|
||||||
|
///
|
||||||
#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \
|
#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \
|
||||||
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, false)
|
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0)
|
||||||
#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
|
#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
|
||||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
|
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, 0)
|
||||||
0, false)
|
|
||||||
#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
|
#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
|
||||||
arg2_name, arg2_val) \
|
arg2_name, arg2_val) \
|
||||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
|
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
|
||||||
arg2_name, arg2_val, false)
|
arg2_name, arg2_val)
|
||||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \
|
|
||||||
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
|
|
||||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
|
|
||||||
0, true)
|
|
||||||
#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
|
|
||||||
arg2_name, arg2_val) \
|
|
||||||
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
|
|
||||||
arg2_name, arg2_val, true)
|
|
||||||
|
|
||||||
// Records a single ASYNC_STEP_INTO event for |step| immediately. If the
|
///
|
||||||
// category is not enabled, then this does nothing. The |name| and |id| must
|
/// Records a single ASYNC_STEP_INTO event for |step| immediately. If the
|
||||||
// match the ASYNC_BEGIN event above. The |step| param identifies this step
|
/// category is not enabled, then this does nothing. The |name| and |id| must
|
||||||
// within the async event. This should be called at the beginning of the next
|
/// match the ASYNC_BEGIN event above. The |step| param identifies this step
|
||||||
// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
|
/// within the async event. This should be called at the beginning of the next
|
||||||
// ASYNC_STEP_PAST events.
|
/// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
|
||||||
|
/// ASYNC_STEP_PAST events.
|
||||||
|
///
|
||||||
#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
|
#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
|
||||||
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, false)
|
cef_trace_event_async_step_into(category, name, id, step, NULL, 0)
|
||||||
#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
|
#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
|
||||||
arg1_val) \
|
arg1_val) \
|
||||||
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
cef_trace_event_async_step_into(category, name, id, step, arg1_name, arg1_val)
|
||||||
arg1_val, false)
|
|
||||||
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO0(category, name, id, step) \
|
|
||||||
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
|
|
||||||
arg1_val) \
|
|
||||||
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
|
|
||||||
arg1_val, true)
|
|
||||||
|
|
||||||
// Records a single ASYNC_STEP_PAST event for |step| immediately. If the
|
///
|
||||||
// category is not enabled, then this does nothing. The |name| and |id| must
|
/// Records a single ASYNC_STEP_PAST event for |step| immediately. If the
|
||||||
// match the ASYNC_BEGIN event above. The |step| param identifies this step
|
/// category is not enabled, then this does nothing. The |name| and |id| must
|
||||||
// within the async event. This should be called at the beginning of the next
|
/// match the ASYNC_BEGIN event above. The |step| param identifies this step
|
||||||
// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
|
/// within the async event. This should be called at the beginning of the next
|
||||||
// ASYNC_STEP_INTO events.
|
/// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
|
||||||
|
/// ASYNC_STEP_INTO events.
|
||||||
|
///
|
||||||
#define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \
|
#define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \
|
||||||
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, false)
|
cef_trace_event_async_step_past(category, name, id, step, NULL, 0)
|
||||||
#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \
|
#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \
|
||||||
arg1_val) \
|
arg1_val) \
|
||||||
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
cef_trace_event_async_step_past(category, name, id, step, arg1_name, arg1_val)
|
||||||
arg1_val, false)
|
|
||||||
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST0(category, name, id, step) \
|
|
||||||
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \
|
|
||||||
arg1_val) \
|
|
||||||
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
|
|
||||||
arg1_val, true)
|
|
||||||
|
|
||||||
// Records a single ASYNC_END event for "name" immediately. If the category
|
///
|
||||||
// is not enabled, then this does nothing.
|
/// Records a single ASYNC_END event for "name" immediately. If the category
|
||||||
|
/// is not enabled, then this does nothing.
|
||||||
|
///
|
||||||
#define TRACE_EVENT_ASYNC_END0(category, name, id) \
|
#define TRACE_EVENT_ASYNC_END0(category, name, id) \
|
||||||
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, false)
|
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0)
|
||||||
#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
|
#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
|
||||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \
|
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0)
|
||||||
false)
|
|
||||||
#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
|
#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
|
||||||
arg2_name, arg2_val) \
|
arg2_name, arg2_val) \
|
||||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
|
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
|
||||||
arg2_name, arg2_val, false)
|
arg2_name, arg2_val)
|
||||||
#define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \
|
|
||||||
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, true)
|
|
||||||
#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
|
|
||||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \
|
|
||||||
true)
|
|
||||||
#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
|
|
||||||
arg2_name, arg2_val) \
|
|
||||||
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
|
|
||||||
arg2_name, arg2_val, true)
|
|
||||||
|
|
||||||
namespace cef_trace_event {
|
namespace cef_trace_event {
|
||||||
|
|
||||||
// Used by TRACE_EVENTx macro. Do not use directly.
|
///
|
||||||
|
/// Used by TRACE_EVENTx macro. Do not use directly.
|
||||||
|
///
|
||||||
class CefTraceEndOnScopeClose {
|
class CefTraceEndOnScopeClose {
|
||||||
public:
|
public:
|
||||||
CefTraceEndOnScopeClose(const char* category, const char* name)
|
CefTraceEndOnScopeClose(const char* category, const char* name)
|
||||||
: category_(category), name_(name) {}
|
: category_(category), name_(name) {}
|
||||||
~CefTraceEndOnScopeClose() {
|
~CefTraceEndOnScopeClose() {
|
||||||
cef_trace_event_end(category_, name_, NULL, 0, NULL, 0, false);
|
cef_trace_event_end(category_, name_, NULL, 0, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -413,7 +377,7 @@ class CefTraceEndOnScopeClose {
|
|||||||
const char* name_;
|
const char* name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // cef_trace_event
|
} // namespace cef_trace_event
|
||||||
|
|
||||||
#endif // !USING_CHROMIUM_INCLUDES
|
#endif // !USING_CHROMIUM_INCLUDES
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -28,80 +28,79 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
// Weak pointers are pointers to an object that do not affect its lifetime,
|
///
|
||||||
// and which may be invalidated (i.e. reset to NULL) by the object, or its
|
/// \file
|
||||||
// owner, at any time, most commonly when the object is about to be deleted.
|
/// Weak pointers are pointers to an object that do not affect its lifetime.
|
||||||
|
/// They may be invalidated (i.e. reset to nullptr) by the object, or its
|
||||||
// Weak pointers are useful when an object needs to be accessed safely by one
|
/// owner, at any time, most commonly when the object is about to be deleted.
|
||||||
// or more objects other than its owner, and those callers can cope with the
|
///
|
||||||
// object vanishing and e.g. tasks posted to it being silently dropped.
|
/// Weak pointers are useful when an object needs to be accessed safely by one
|
||||||
// Reference-counting such an object would complicate the ownership graph and
|
/// or more objects other than its owner, and those callers can cope with the
|
||||||
// make it harder to reason about the object's lifetime.
|
/// object vanishing and e.g. tasks posted to it being silently dropped.
|
||||||
|
/// Reference-counting such an object would complicate the ownership graph and
|
||||||
// EXAMPLE:
|
/// make it harder to reason about the object's lifetime.
|
||||||
//
|
///
|
||||||
// class Controller {
|
/// EXAMPLE:
|
||||||
// public:
|
///
|
||||||
// Controller() : weak_factory_(this) {}
|
/// <pre>
|
||||||
// void SpawnWorker() { Worker::StartNew(weak_factory_.GetWeakPtr()); }
|
/// class Controller {
|
||||||
// void WorkComplete(const Result& result) { ... }
|
/// public:
|
||||||
// private:
|
/// void SpawnWorker() { Worker::StartNew(weak_factory_.GetWeakPtr()); }
|
||||||
// // Member variables should appear before the WeakPtrFactory, to ensure
|
/// void WorkComplete(const Result& result) { ... }
|
||||||
// // that any WeakPtrs to Controller are invalidated before its members
|
/// private:
|
||||||
// // variable's destructors are executed, rendering them invalid.
|
/// // Member variables should appear before the WeakPtrFactory, to ensure
|
||||||
// WeakPtrFactory<Controller> weak_factory_;
|
/// // that any WeakPtrs to Controller are invalidated before its members
|
||||||
// };
|
/// // variable's destructors are executed, rendering them invalid.
|
||||||
//
|
/// WeakPtrFactory<Controller> weak_factory_{this};
|
||||||
// class Worker {
|
/// };
|
||||||
// public:
|
///
|
||||||
// static void StartNew(const WeakPtr<Controller>& controller) {
|
/// class Worker {
|
||||||
// Worker* worker = new Worker(controller);
|
/// public:
|
||||||
// // Kick off asynchronous processing...
|
/// static void StartNew(WeakPtr<Controller> controller) {
|
||||||
// }
|
/// Worker* worker = new Worker(std::move(controller));
|
||||||
// private:
|
/// // Kick off asynchronous processing...
|
||||||
// Worker(const WeakPtr<Controller>& controller)
|
/// }
|
||||||
// : controller_(controller) {}
|
/// private:
|
||||||
// void DidCompleteAsynchronousProcessing(const Result& result) {
|
/// Worker(WeakPtr<Controller> controller)
|
||||||
// if (controller_)
|
/// : controller_(std::move(controller)) {}
|
||||||
// controller_->WorkComplete(result);
|
/// void DidCompleteAsynchronousProcessing(const Result& result) {
|
||||||
// }
|
/// if (controller_)
|
||||||
// WeakPtr<Controller> controller_;
|
/// controller_->WorkComplete(result);
|
||||||
// };
|
/// }
|
||||||
//
|
/// WeakPtr<Controller> controller_;
|
||||||
// With this implementation a caller may use SpawnWorker() to dispatch multiple
|
/// };
|
||||||
// Workers and subsequently delete the Controller, without waiting for all
|
/// </pre>
|
||||||
// Workers to have completed.
|
///
|
||||||
|
/// With this implementation a caller may use SpawnWorker() to dispatch multiple
|
||||||
// ------------------------- IMPORTANT: Thread-safety -------------------------
|
/// Workers and subsequently delete the Controller, without waiting for all
|
||||||
|
/// Workers to have completed.
|
||||||
// Weak pointers may be passed safely between threads, but must always be
|
///
|
||||||
// dereferenced and invalidated on the same thread otherwise checking the
|
/// <b>IMPORTANT: Thread-safety</b>
|
||||||
// pointer would be racey.
|
///
|
||||||
//
|
/// Weak pointers may be passed safely between threads, but must always be
|
||||||
// To ensure correct use, the first time a WeakPtr issued by a WeakPtrFactory
|
/// dereferenced and invalidated on the same ThreaddTaskRunner otherwise
|
||||||
// is dereferenced, the factory and its WeakPtrs become bound to the calling
|
/// checking the pointer would be racey.
|
||||||
// thread, and cannot be dereferenced or invalidated on any other thread. Bound
|
///
|
||||||
// WeakPtrs can still be handed off to other threads, e.g. to use to post tasks
|
/// To ensure correct use, the first time a WeakPtr issued by a WeakPtrFactory
|
||||||
// back to object on the bound thread.
|
/// is dereferenced, the factory and its WeakPtrs become bound to the calling
|
||||||
//
|
/// thread or current ThreaddWorkerPool token, and cannot be dereferenced or
|
||||||
// If all WeakPtr objects are destroyed or invalidated then the factory is
|
/// invalidated on any other task runner. Bound WeakPtrs can still be handed
|
||||||
// unbound from the SequencedTaskRunner/Thread. The WeakPtrFactory may then be
|
/// off to other task runners, e.g. to use to post tasks back to object on the
|
||||||
// destroyed, or new WeakPtr objects may be used, from a different sequence.
|
/// bound thread.
|
||||||
//
|
///
|
||||||
// Thus, at least one WeakPtr object must exist and have been dereferenced on
|
/// If all WeakPtr objects are destroyed or invalidated then the factory is
|
||||||
// the correct thread to enforce that other WeakPtr objects will enforce they
|
/// unbound from the ThreadedTaskRunner/Thread. The WeakPtrFactory may then be
|
||||||
// are used on the desired thread.
|
/// destroyed, or new WeakPtr objects may be used, from a different thread.
|
||||||
|
///
|
||||||
|
/// Thus, at least one WeakPtr object must exist and have been dereferenced on
|
||||||
|
/// the correct thread to enforce that other WeakPtr objects will enforce they
|
||||||
|
/// are used on the desired thread.
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
#ifndef CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
||||||
#define CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
#define CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(BASE_MEMORY_WEAK_PTR_H_)
|
#if defined(USING_CHROMIUM_INCLUDES)
|
||||||
// Do nothing if the Chromium header has already been included.
|
|
||||||
// This can happen in cases where Chromium code is used directly by the
|
|
||||||
// client application. When using Chromium code directly always include
|
|
||||||
// the Chromium header first to avoid type conflicts.
|
|
||||||
#elif defined(USING_CHROMIUM_INCLUDES)
|
|
||||||
// When building CEF include the Chromium header directly.
|
// When building CEF include the Chromium header directly.
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#else // !USING_CHROMIUM_INCLUDES
|
#else // !USING_CHROMIUM_INCLUDES
|
||||||
@@ -109,10 +108,12 @@
|
|||||||
// If the Chromium implementation diverges the below implementation should be
|
// If the Chromium implementation diverges the below implementation should be
|
||||||
// updated to match.
|
// updated to match.
|
||||||
|
|
||||||
#include "include/base/cef_basictypes.h"
|
#include <cstddef>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "include/base/cef_atomic_flag.h"
|
||||||
#include "include/base/cef_logging.h"
|
#include "include/base/cef_logging.h"
|
||||||
#include "include/base/cef_ref_counted.h"
|
#include "include/base/cef_ref_counted.h"
|
||||||
#include "include/base/cef_template_util.h"
|
|
||||||
#include "include/base/cef_thread_checker.h"
|
#include "include/base/cef_thread_checker.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
@@ -128,8 +129,8 @@ namespace cef_internal {
|
|||||||
|
|
||||||
class WeakReference {
|
class WeakReference {
|
||||||
public:
|
public:
|
||||||
// Although Flag is bound to a specific thread, it may be deleted from another
|
// Although Flag is bound to a specific ThreaddTaskRunner, it may be
|
||||||
// via base::WeakPtr::~WeakPtr().
|
// deleted from another via base::WeakPtr::~WeakPtr().
|
||||||
class Flag : public RefCountedThreadSafe<Flag> {
|
class Flag : public RefCountedThreadSafe<Flag> {
|
||||||
public:
|
public:
|
||||||
Flag();
|
Flag();
|
||||||
@@ -137,23 +138,30 @@ class WeakReference {
|
|||||||
void Invalidate();
|
void Invalidate();
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
|
|
||||||
|
bool MaybeValid() const;
|
||||||
|
|
||||||
|
void DetachFromThread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class base::RefCountedThreadSafe<Flag>;
|
friend class base::RefCountedThreadSafe<Flag>;
|
||||||
|
|
||||||
~Flag();
|
~Flag();
|
||||||
|
|
||||||
// The current Chromium implementation uses SequenceChecker instead of
|
base::ThreadChecker thread_checker_;
|
||||||
// ThreadChecker to support SequencedWorkerPools. CEF does not yet expose
|
AtomicFlag invalidated_;
|
||||||
// the concept of SequencedWorkerPools.
|
|
||||||
ThreadChecker thread_checker_;
|
|
||||||
bool is_valid_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WeakReference();
|
WeakReference();
|
||||||
explicit WeakReference(const Flag* flag);
|
explicit WeakReference(const scoped_refptr<Flag>& flag);
|
||||||
~WeakReference();
|
~WeakReference();
|
||||||
|
|
||||||
bool is_valid() const;
|
WeakReference(WeakReference&& other) noexcept;
|
||||||
|
WeakReference(const WeakReference& other);
|
||||||
|
WeakReference& operator=(WeakReference&& other) noexcept = default;
|
||||||
|
WeakReference& operator=(const WeakReference& other) = default;
|
||||||
|
|
||||||
|
bool IsValid() const;
|
||||||
|
bool MaybeValid() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
scoped_refptr<const Flag> flag_;
|
scoped_refptr<const Flag> flag_;
|
||||||
@@ -166,12 +174,12 @@ class WeakReferenceOwner {
|
|||||||
|
|
||||||
WeakReference GetRef() const;
|
WeakReference GetRef() const;
|
||||||
|
|
||||||
bool HasRefs() const { return flag_.get() && !flag_->HasOneRef(); }
|
bool HasRefs() const { return !flag_->HasOneRef(); }
|
||||||
|
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable scoped_refptr<WeakReference::Flag> flag_;
|
scoped_refptr<WeakReference::Flag> flag_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class simplifies the implementation of WeakPtr's type conversion
|
// This class simplifies the implementation of WeakPtr's type conversion
|
||||||
@@ -183,10 +191,24 @@ class WeakPtrBase {
|
|||||||
WeakPtrBase();
|
WeakPtrBase();
|
||||||
~WeakPtrBase();
|
~WeakPtrBase();
|
||||||
|
|
||||||
|
WeakPtrBase(const WeakPtrBase& other) = default;
|
||||||
|
WeakPtrBase(WeakPtrBase&& other) noexcept = default;
|
||||||
|
WeakPtrBase& operator=(const WeakPtrBase& other) = default;
|
||||||
|
WeakPtrBase& operator=(WeakPtrBase&& other) noexcept = default;
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
ref_ = cef_internal::WeakReference();
|
||||||
|
ptr_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit WeakPtrBase(const WeakReference& ref);
|
WeakPtrBase(const WeakReference& ref, uintptr_t ptr);
|
||||||
|
|
||||||
WeakReference ref_;
|
WeakReference ref_;
|
||||||
|
|
||||||
|
// This pointer is only valid when ref_.is_valid() is true. Otherwise, its
|
||||||
|
// value is undefined (as opposed to nullptr).
|
||||||
|
uintptr_t ptr_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class provides a common implementation of common functions that would
|
// This class provides a common implementation of common functions that would
|
||||||
@@ -198,13 +220,14 @@ class SupportsWeakPtrBase {
|
|||||||
// conversion will only compile if there is exists a Base which inherits
|
// conversion will only compile if there is exists a Base which inherits
|
||||||
// from SupportsWeakPtr<Base>. See base::AsWeakPtr() below for a helper
|
// from SupportsWeakPtr<Base>. See base::AsWeakPtr() below for a helper
|
||||||
// function that makes calling this easier.
|
// function that makes calling this easier.
|
||||||
|
//
|
||||||
|
// Precondition: t != nullptr
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) {
|
static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) {
|
||||||
typedef is_convertible<Derived, cef_internal::SupportsWeakPtrBase&>
|
static_assert(
|
||||||
convertible;
|
std::is_base_of<cef_internal::SupportsWeakPtrBase, Derived>::value,
|
||||||
COMPILE_ASSERT(convertible::value,
|
"AsWeakPtr argument must inherit from SupportsWeakPtr");
|
||||||
AsWeakPtr_argument_inherits_from_SupportsWeakPtr);
|
return AsWeakPtrImpl<Derived>(t);
|
||||||
return AsWeakPtrImpl<Derived>(t, *t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -212,10 +235,10 @@ class SupportsWeakPtrBase {
|
|||||||
// which is an instance of SupportsWeakPtr<Base>. We can then safely
|
// which is an instance of SupportsWeakPtr<Base>. We can then safely
|
||||||
// static_cast the Base* to a Derived*.
|
// static_cast the Base* to a Derived*.
|
||||||
template <typename Derived, typename Base>
|
template <typename Derived, typename Base>
|
||||||
static WeakPtr<Derived> AsWeakPtrImpl(Derived* t,
|
static WeakPtr<Derived> AsWeakPtrImpl(SupportsWeakPtr<Base>* t) {
|
||||||
const SupportsWeakPtr<Base>&) {
|
WeakPtr<Base> ptr = t->AsWeakPtr();
|
||||||
WeakPtr<Base> ptr = t->Base::AsWeakPtr();
|
return WeakPtr<Derived>(
|
||||||
return WeakPtr<Derived>(ptr.ref_, static_cast<Derived*>(ptr.ptr_));
|
ptr.ref_, static_cast<Derived*>(reinterpret_cast<Base*>(ptr.ptr_)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -224,66 +247,84 @@ class SupportsWeakPtrBase {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class WeakPtrFactory;
|
class WeakPtrFactory;
|
||||||
|
|
||||||
// The WeakPtr class holds a weak reference to |T*|.
|
///
|
||||||
//
|
/// The WeakPtr class holds a weak reference to |T*|.
|
||||||
// This class is designed to be used like a normal pointer. You should always
|
///
|
||||||
// null-test an object of this class before using it or invoking a method that
|
/// This class is designed to be used like a normal pointer. You should always
|
||||||
// may result in the underlying object being destroyed.
|
/// null-test an object of this class before using it or invoking a method that
|
||||||
//
|
/// may result in the underlying object being destroyed.
|
||||||
// EXAMPLE:
|
///
|
||||||
//
|
/// EXAMPLE:
|
||||||
// class Foo { ... };
|
///
|
||||||
// WeakPtr<Foo> foo;
|
/// <pre>
|
||||||
// if (foo)
|
/// class Foo { ... };
|
||||||
// foo->method();
|
/// WeakPtr<Foo> foo;
|
||||||
//
|
/// if (foo)
|
||||||
|
/// foo->method();
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class WeakPtr : public cef_internal::WeakPtrBase {
|
class WeakPtr : public cef_internal::WeakPtrBase {
|
||||||
public:
|
public:
|
||||||
WeakPtr() : ptr_(NULL) {}
|
WeakPtr() = default;
|
||||||
|
WeakPtr(std::nullptr_t) {}
|
||||||
|
|
||||||
// Allow conversion from U to T provided U "is a" T. Note that this
|
///
|
||||||
// is separate from the (implicit) copy constructor.
|
/// Allow conversion from U to T provided U "is a" T. Note that this
|
||||||
|
/// is separate from the (implicit) copy and move constructors.
|
||||||
|
///
|
||||||
template <typename U>
|
template <typename U>
|
||||||
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other), ptr_(other.ptr_) {}
|
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other) {
|
||||||
|
// Need to cast from U* to T* to do pointer adjustment in case of multiple
|
||||||
|
// inheritance. This also enforces the "U is a T" rule.
|
||||||
|
T* t = reinterpret_cast<U*>(other.ptr_);
|
||||||
|
ptr_ = reinterpret_cast<uintptr_t>(t);
|
||||||
|
}
|
||||||
|
template <typename U>
|
||||||
|
WeakPtr(WeakPtr<U>&& other) noexcept : WeakPtrBase(std::move(other)) {
|
||||||
|
// Need to cast from U* to T* to do pointer adjustment in case of multiple
|
||||||
|
// inheritance. This also enforces the "U is a T" rule.
|
||||||
|
T* t = reinterpret_cast<U*>(other.ptr_);
|
||||||
|
ptr_ = reinterpret_cast<uintptr_t>(t);
|
||||||
|
}
|
||||||
|
|
||||||
T* get() const { return ref_.is_valid() ? ptr_ : NULL; }
|
T* get() const {
|
||||||
|
return ref_.IsValid() ? reinterpret_cast<T*>(ptr_) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
T& operator*() const {
|
T& operator*() const {
|
||||||
DCHECK(get() != NULL);
|
CHECK(ref_.IsValid());
|
||||||
return *get();
|
return *get();
|
||||||
}
|
}
|
||||||
T* operator->() const {
|
T* operator->() const {
|
||||||
DCHECK(get() != NULL);
|
CHECK(ref_.IsValid());
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow WeakPtr<element_type> to be used in boolean expressions, but not
|
///
|
||||||
// implicitly convertible to a real bool (which is dangerous).
|
/// Allow conditionals to test validity, e.g. `if (weak_ptr) {...}`;
|
||||||
//
|
///
|
||||||
// Note that this trick is only safe when the == and != operators
|
explicit operator bool() const { return get() != nullptr; }
|
||||||
// are declared explicitly, as otherwise "weak_ptr1 == weak_ptr2"
|
|
||||||
// will compile but do the wrong thing (i.e., convert to Testable
|
|
||||||
// and then do the comparison).
|
|
||||||
private:
|
|
||||||
typedef T* WeakPtr::*Testable;
|
|
||||||
|
|
||||||
public:
|
///
|
||||||
operator Testable() const { return get() ? &WeakPtr::ptr_ : NULL; }
|
/// Returns false if the WeakPtr is confirmed to be invalid. This call is safe
|
||||||
|
/// to make from any thread, e.g. to optimize away unnecessary work, but
|
||||||
|
/// operator bool() must always be called, on the correct thread, before
|
||||||
|
/// actually using the pointer.
|
||||||
|
///
|
||||||
|
/// Warning: as with any object, this call is only thread-safe if the WeakPtr
|
||||||
|
/// instance isn't being re-assigned or reset() racily with this call.
|
||||||
|
///
|
||||||
|
bool MaybeValid() const { return ref_.MaybeValid(); }
|
||||||
|
|
||||||
void reset() {
|
///
|
||||||
ref_ = cef_internal::WeakReference();
|
/// Returns whether the object |this| points to has been invalidated. This can
|
||||||
ptr_ = NULL;
|
/// be used to distinguish a WeakPtr to a destroyed object from one that has
|
||||||
}
|
/// been explicitly set to null.
|
||||||
|
///
|
||||||
|
bool WasInvalidated() const { return ptr_ && !ref_.IsValid(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Explicitly declare comparison operators as required by the bool
|
|
||||||
// trick, but keep them private.
|
|
||||||
template <class U>
|
|
||||||
bool operator==(WeakPtr<U> const&) const;
|
|
||||||
template <class U>
|
|
||||||
bool operator!=(WeakPtr<U> const&) const;
|
|
||||||
|
|
||||||
friend class cef_internal::SupportsWeakPtrBase;
|
friend class cef_internal::SupportsWeakPtrBase;
|
||||||
template <typename U>
|
template <typename U>
|
||||||
friend class WeakPtr;
|
friend class WeakPtr;
|
||||||
@@ -291,88 +332,131 @@ class WeakPtr : public cef_internal::WeakPtrBase {
|
|||||||
friend class WeakPtrFactory<T>;
|
friend class WeakPtrFactory<T>;
|
||||||
|
|
||||||
WeakPtr(const cef_internal::WeakReference& ref, T* ptr)
|
WeakPtr(const cef_internal::WeakReference& ref, T* ptr)
|
||||||
: WeakPtrBase(ref), ptr_(ptr) {}
|
: WeakPtrBase(ref, reinterpret_cast<uintptr_t>(ptr)) {}
|
||||||
|
|
||||||
// This pointer is only valid when ref_.is_valid() is true. Otherwise, its
|
|
||||||
// value is undefined (as opposed to NULL).
|
|
||||||
T* ptr_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A class may be composed of a WeakPtrFactory and thereby
|
///
|
||||||
// control how it exposes weak pointers to itself. This is helpful if you only
|
/// Allow callers to compare WeakPtrs against nullptr to test validity.
|
||||||
// need weak pointers within the implementation of a class. This class is also
|
///
|
||||||
// useful when working with primitive types. For example, you could have a
|
|
||||||
// WeakPtrFactory<bool> that is used to pass around a weak reference to a bool.
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class WeakPtrFactory {
|
bool operator!=(const WeakPtr<T>& weak_ptr, std::nullptr_t) {
|
||||||
|
return !(weak_ptr == nullptr);
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
bool operator!=(std::nullptr_t, const WeakPtr<T>& weak_ptr) {
|
||||||
|
return weak_ptr != nullptr;
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
bool operator==(const WeakPtr<T>& weak_ptr, std::nullptr_t) {
|
||||||
|
return weak_ptr.get() == nullptr;
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
bool operator==(std::nullptr_t, const WeakPtr<T>& weak_ptr) {
|
||||||
|
return weak_ptr == nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace cef_internal {
|
||||||
|
class WeakPtrFactoryBase {
|
||||||
|
protected:
|
||||||
|
WeakPtrFactoryBase(uintptr_t ptr);
|
||||||
|
~WeakPtrFactoryBase();
|
||||||
|
cef_internal::WeakReferenceOwner weak_reference_owner_;
|
||||||
|
uintptr_t ptr_;
|
||||||
|
};
|
||||||
|
} // namespace cef_internal
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A class may be composed of a WeakPtrFactory and thereby control how it
|
||||||
|
/// exposes weak pointers to itself. This is helpful if you only need weak
|
||||||
|
/// pointers within the implementation of a class. This class is also useful
|
||||||
|
/// when working with primitive types. For example, you could have a
|
||||||
|
/// WeakPtrFactory<bool> that is used to pass around a weak reference to a
|
||||||
|
/// bool.
|
||||||
|
///
|
||||||
|
template <class T>
|
||||||
|
class WeakPtrFactory : public cef_internal::WeakPtrFactoryBase {
|
||||||
public:
|
public:
|
||||||
explicit WeakPtrFactory(T* ptr) : ptr_(ptr) {}
|
WeakPtrFactory() = delete;
|
||||||
|
|
||||||
~WeakPtrFactory() { ptr_ = NULL; }
|
explicit WeakPtrFactory(T* ptr)
|
||||||
|
: WeakPtrFactoryBase(reinterpret_cast<uintptr_t>(ptr)) {}
|
||||||
|
|
||||||
WeakPtr<T> GetWeakPtr() {
|
WeakPtrFactory(const WeakPtrFactory&) = delete;
|
||||||
DCHECK(ptr_);
|
WeakPtrFactory& operator=(const WeakPtrFactory&) = delete;
|
||||||
return WeakPtr<T>(weak_reference_owner_.GetRef(), ptr_);
|
|
||||||
|
~WeakPtrFactory() = default;
|
||||||
|
|
||||||
|
WeakPtr<T> GetWeakPtr() const {
|
||||||
|
return WeakPtr<T>(weak_reference_owner_.GetRef(),
|
||||||
|
reinterpret_cast<T*>(ptr_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call this method to invalidate all existing weak pointers.
|
///
|
||||||
|
/// Call this method to invalidate all existing weak pointers.
|
||||||
|
///
|
||||||
void InvalidateWeakPtrs() {
|
void InvalidateWeakPtrs() {
|
||||||
DCHECK(ptr_);
|
DCHECK(ptr_);
|
||||||
weak_reference_owner_.Invalidate();
|
weak_reference_owner_.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call this method to determine if any weak pointers exist.
|
///
|
||||||
|
/// Call this method to determine if any weak pointers exist.
|
||||||
|
///
|
||||||
bool HasWeakPtrs() const {
|
bool HasWeakPtrs() const {
|
||||||
DCHECK(ptr_);
|
DCHECK(ptr_);
|
||||||
return weak_reference_owner_.HasRefs();
|
return weak_reference_owner_.HasRefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
cef_internal::WeakReferenceOwner weak_reference_owner_;
|
|
||||||
T* ptr_;
|
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(WeakPtrFactory);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A class may extend from SupportsWeakPtr to let others take weak pointers to
|
///
|
||||||
// it. This avoids the class itself implementing boilerplate to dispense weak
|
/// A class may extend from SupportsWeakPtr to let others take weak pointers to
|
||||||
// pointers. However, since SupportsWeakPtr's destructor won't invalidate
|
/// it. This avoids the class itself implementing boilerplate to dispense weak
|
||||||
// weak pointers to the class until after the derived class' members have been
|
/// pointers. However, since SupportsWeakPtr's destructor won't invalidate
|
||||||
// destroyed, its use can lead to subtle use-after-destroy issues.
|
/// weak pointers to the class until after the derived class' members have been
|
||||||
|
/// destroyed, its use can lead to subtle use-after-destroy issues.
|
||||||
|
///
|
||||||
template <class T>
|
template <class T>
|
||||||
class SupportsWeakPtr : public cef_internal::SupportsWeakPtrBase {
|
class SupportsWeakPtr : public cef_internal::SupportsWeakPtrBase {
|
||||||
public:
|
public:
|
||||||
SupportsWeakPtr() {}
|
SupportsWeakPtr() = default;
|
||||||
|
|
||||||
|
SupportsWeakPtr(const SupportsWeakPtr&) = delete;
|
||||||
|
SupportsWeakPtr& operator=(const SupportsWeakPtr&) = delete;
|
||||||
|
|
||||||
WeakPtr<T> AsWeakPtr() {
|
WeakPtr<T> AsWeakPtr() {
|
||||||
return WeakPtr<T>(weak_reference_owner_.GetRef(), static_cast<T*>(this));
|
return WeakPtr<T>(weak_reference_owner_.GetRef(), static_cast<T*>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~SupportsWeakPtr() {}
|
~SupportsWeakPtr() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cef_internal::WeakReferenceOwner weak_reference_owner_;
|
cef_internal::WeakReferenceOwner weak_reference_owner_;
|
||||||
DISALLOW_COPY_AND_ASSIGN(SupportsWeakPtr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Helper function that uses type deduction to safely return a WeakPtr<Derived>
|
///
|
||||||
// when Derived doesn't directly extend SupportsWeakPtr<Derived>, instead it
|
/// Helper function that uses type deduction to safely return a WeakPtr<Derived>
|
||||||
// extends a Base that extends SupportsWeakPtr<Base>.
|
/// when Derived doesn't directly extend SupportsWeakPtr<Derived>, instead it
|
||||||
//
|
/// extends a Base that extends SupportsWeakPtr<Base>.
|
||||||
// EXAMPLE:
|
///
|
||||||
// class Base : public base::SupportsWeakPtr<Producer> {};
|
/// EXAMPLE:
|
||||||
// class Derived : public Base {};
|
/// <pre>
|
||||||
//
|
/// class Base : public base::SupportsWeakPtr<Producer> {};
|
||||||
// Derived derived;
|
/// class Derived : public Base {};
|
||||||
// base::WeakPtr<Derived> ptr = base::AsWeakPtr(&derived);
|
///
|
||||||
//
|
/// Derived derived;
|
||||||
// Note that the following doesn't work (invalid type conversion) since
|
/// base::WeakPtr<Derived> ptr = base::AsWeakPtr(&derived);
|
||||||
// Derived::AsWeakPtr() is WeakPtr<Base> SupportsWeakPtr<Base>::AsWeakPtr(),
|
/// </pre>
|
||||||
// and there's no way to safely cast WeakPtr<Base> to WeakPtr<Derived> at
|
///
|
||||||
// the caller.
|
/// Note that the following doesn't work (invalid type conversion) since
|
||||||
//
|
/// Derived::AsWeakPtr() is WeakPtr<Base> SupportsWeakPtr<Base>::AsWeakPtr(),
|
||||||
// base::WeakPtr<Derived> ptr = derived.AsWeakPtr(); // Fails.
|
/// and there's no way to safely cast WeakPtr<Base> to WeakPtr<Derived> at
|
||||||
|
/// the caller.
|
||||||
|
///
|
||||||
|
/// <pre>
|
||||||
|
/// base::WeakPtr<Derived> ptr = derived.AsWeakPtr(); // Fails.
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
WeakPtr<Derived> AsWeakPtr(Derived* t) {
|
WeakPtr<Derived> AsWeakPtr(Derived* t) {
|
||||||
return cef_internal::SupportsWeakPtrBase::StaticAsWeakPtr<Derived>(t);
|
return cef_internal::SupportsWeakPtrBase::StaticAsWeakPtr<Derived>(t);
|
||||||
|
|||||||
@@ -1,325 +0,0 @@
|
|||||||
// Copyright (c) 2013 Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
//
|
|
||||||
// Do not include this header file directly. Use base/cef_atomicops.h
|
|
||||||
// instead.
|
|
||||||
//
|
|
||||||
// LinuxKernelCmpxchg and Barrier_AtomicIncrement are from Google Gears.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM_GCC_H_
|
|
||||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM_GCC_H_
|
|
||||||
|
|
||||||
#if defined(OS_QNX)
|
|
||||||
#include <sys/cpuinline.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
namespace subtle {
|
|
||||||
|
|
||||||
// Memory barriers on ARM are funky, but the kernel is here to help:
|
|
||||||
//
|
|
||||||
// * ARMv5 didn't support SMP, there is no memory barrier instruction at
|
|
||||||
// all on this architecture, or when targeting its machine code.
|
|
||||||
//
|
|
||||||
// * Some ARMv6 CPUs support SMP. A full memory barrier can be produced by
|
|
||||||
// writing a random value to a very specific coprocessor register.
|
|
||||||
//
|
|
||||||
// * On ARMv7, the "dmb" instruction is used to perform a full memory
|
|
||||||
// barrier (though writing to the co-processor will still work).
|
|
||||||
// However, on single core devices (e.g. Nexus One, or Nexus S),
|
|
||||||
// this instruction will take up to 200 ns, which is huge, even though
|
|
||||||
// it's completely un-needed on these devices.
|
|
||||||
//
|
|
||||||
// * There is no easy way to determine at runtime if the device is
|
|
||||||
// single or multi-core. However, the kernel provides a useful helper
|
|
||||||
// function at a fixed memory address (0xffff0fa0), which will always
|
|
||||||
// perform a memory barrier in the most efficient way. I.e. on single
|
|
||||||
// core devices, this is an empty function that exits immediately.
|
|
||||||
// On multi-core devices, it implements a full memory barrier.
|
|
||||||
//
|
|
||||||
// * This source could be compiled to ARMv5 machine code that runs on a
|
|
||||||
// multi-core ARMv6 or ARMv7 device. In this case, memory barriers
|
|
||||||
// are needed for correct execution. Always call the kernel helper, even
|
|
||||||
// when targeting ARMv5TE.
|
|
||||||
//
|
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
|
||||||
#if defined(OS_LINUX) || defined(OS_ANDROID)
|
|
||||||
// Note: This is a function call, which is also an implicit compiler barrier.
|
|
||||||
typedef void (*KernelMemoryBarrierFunc)();
|
|
||||||
((KernelMemoryBarrierFunc)0xffff0fa0)();
|
|
||||||
#elif defined(OS_QNX)
|
|
||||||
__cpu_membarrier();
|
|
||||||
#else
|
|
||||||
#error MemoryBarrier() is not implemented on this platform.
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// An ARM toolchain would only define one of these depending on which
|
|
||||||
// variant of the target architecture is being used. This tests against
|
|
||||||
// any known ARMv6 or ARMv7 variant, where it is possible to directly
|
|
||||||
// use ldrex/strex instructions to implement fast atomic operations.
|
|
||||||
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
|
|
||||||
defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || \
|
|
||||||
defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
|
|
||||||
defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
|
|
||||||
defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__)
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 prev_value;
|
|
||||||
int reloop;
|
|
||||||
do {
|
|
||||||
// The following is equivalent to:
|
|
||||||
//
|
|
||||||
// prev_value = LDREX(ptr)
|
|
||||||
// reloop = 0
|
|
||||||
// if (prev_value != old_value)
|
|
||||||
// reloop = STREX(ptr, new_value)
|
|
||||||
__asm__ __volatile__(
|
|
||||||
" ldrex %0, [%3]\n"
|
|
||||||
" mov %1, #0\n"
|
|
||||||
" cmp %0, %4\n"
|
|
||||||
#ifdef __thumb2__
|
|
||||||
" it eq\n"
|
|
||||||
#endif
|
|
||||||
" strexeq %1, %5, [%3]\n"
|
|
||||||
: "=&r"(prev_value), "=&r"(reloop), "+m"(*ptr)
|
|
||||||
: "r"(ptr), "r"(old_value), "r"(new_value)
|
|
||||||
: "cc", "memory");
|
|
||||||
} while (reloop != 0);
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 result = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
MemoryBarrier();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
Atomic32 value;
|
|
||||||
int reloop;
|
|
||||||
do {
|
|
||||||
// Equivalent to:
|
|
||||||
//
|
|
||||||
// value = LDREX(ptr)
|
|
||||||
// value += increment
|
|
||||||
// reloop = STREX(ptr, value)
|
|
||||||
//
|
|
||||||
__asm__ __volatile__(
|
|
||||||
" ldrex %0, [%3]\n"
|
|
||||||
" add %0, %0, %4\n"
|
|
||||||
" strex %1, %0, [%3]\n"
|
|
||||||
: "=&r"(value), "=&r"(reloop), "+m"(*ptr)
|
|
||||||
: "r"(ptr), "r"(increment)
|
|
||||||
: "cc", "memory");
|
|
||||||
} while (reloop);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
// TODO(digit): Investigate if it's possible to implement this with
|
|
||||||
// a single MemoryBarrier() operation between the LDREX and STREX.
|
|
||||||
// See http://crbug.com/246514
|
|
||||||
MemoryBarrier();
|
|
||||||
Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment);
|
|
||||||
MemoryBarrier();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 old_value;
|
|
||||||
int reloop;
|
|
||||||
do {
|
|
||||||
// old_value = LDREX(ptr)
|
|
||||||
// reloop = STREX(ptr, new_value)
|
|
||||||
__asm__ __volatile__(
|
|
||||||
" ldrex %0, [%3]\n"
|
|
||||||
" strex %1, %4, [%3]\n"
|
|
||||||
: "=&r"(old_value), "=&r"(reloop), "+m"(*ptr)
|
|
||||||
: "r"(ptr), "r"(new_value)
|
|
||||||
: "cc", "memory");
|
|
||||||
} while (reloop != 0);
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This tests against any known ARMv5 variant.
|
|
||||||
#elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
|
|
||||||
defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
|
|
||||||
|
|
||||||
// The kernel also provides a helper function to perform an atomic
|
|
||||||
// compare-and-swap operation at the hard-wired address 0xffff0fc0.
|
|
||||||
// On ARMv5, this is implemented by a special code path that the kernel
|
|
||||||
// detects and treats specially when thread pre-emption happens.
|
|
||||||
// On ARMv6 and higher, it uses LDREX/STREX instructions instead.
|
|
||||||
//
|
|
||||||
// Note that this always perform a full memory barrier, there is no
|
|
||||||
// need to add calls MemoryBarrier() before or after it. It also
|
|
||||||
// returns 0 on success, and 1 on exit.
|
|
||||||
//
|
|
||||||
// Available and reliable since Linux 2.6.24. Both Android and ChromeOS
|
|
||||||
// use newer kernel revisions, so this should not be a concern.
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
inline int LinuxKernelCmpxchg(Atomic32 old_value,
|
|
||||||
Atomic32 new_value,
|
|
||||||
volatile Atomic32* ptr) {
|
|
||||||
typedef int (*KernelCmpxchgFunc)(Atomic32, Atomic32, volatile Atomic32*);
|
|
||||||
return ((KernelCmpxchgFunc)0xffff0fc0)(old_value, new_value, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 prev_value;
|
|
||||||
for (;;) {
|
|
||||||
prev_value = *ptr;
|
|
||||||
if (prev_value != old_value)
|
|
||||||
return prev_value;
|
|
||||||
if (!LinuxKernelCmpxchg(old_value, new_value, ptr))
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 old_value;
|
|
||||||
do {
|
|
||||||
old_value = *ptr;
|
|
||||||
} while (LinuxKernelCmpxchg(old_value, new_value, ptr));
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
return Barrier_AtomicIncrement(ptr, increment);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
for (;;) {
|
|
||||||
// Atomic exchange the old value with an incremented one.
|
|
||||||
Atomic32 old_value = *ptr;
|
|
||||||
Atomic32 new_value = old_value + increment;
|
|
||||||
if (!LinuxKernelCmpxchg(old_value, new_value, ptr)) {
|
|
||||||
// The exchange took place as expected.
|
|
||||||
return new_value;
|
|
||||||
}
|
|
||||||
// Otherwise, *ptr changed mid-loop and we need to retry.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 prev_value;
|
|
||||||
for (;;) {
|
|
||||||
prev_value = *ptr;
|
|
||||||
if (prev_value != old_value) {
|
|
||||||
// Always ensure acquire semantics.
|
|
||||||
MemoryBarrier();
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
if (!LinuxKernelCmpxchg(old_value, new_value, ptr))
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
// This could be implemented as:
|
|
||||||
// MemoryBarrier();
|
|
||||||
// return NoBarrier_CompareAndSwap();
|
|
||||||
//
|
|
||||||
// But would use 3 barriers per succesful CAS. To save performance,
|
|
||||||
// use Acquire_CompareAndSwap(). Its implementation guarantees that:
|
|
||||||
// - A succesful swap uses only 2 barriers (in the kernel helper).
|
|
||||||
// - An early return due to (prev_value != old_value) performs
|
|
||||||
// a memory barrier with no store, which is equivalent to the
|
|
||||||
// generic implementation above.
|
|
||||||
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error "Your CPU's ARM architecture is not supported yet"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// NOTE: Atomicity of the following load and store operations is only
|
|
||||||
// guaranteed in case of 32-bit alignement of |ptr| values.
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value;
|
|
||||||
MemoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
MemoryBarrier();
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
|
||||||
Atomic32 value = *ptr;
|
|
||||||
MemoryBarrier();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace base::subtle
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ARM_GCC_H_
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
// Copyright (c) 2011 Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// Do not include this header file directly. Use base/cef_atomicops.h
|
|
||||||
// instead.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ATOMICWORD_COMPAT_H_
|
|
||||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ATOMICWORD_COMPAT_H_
|
|
||||||
|
|
||||||
// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32,
|
|
||||||
// which in turn means int. On some LP32 platforms, intptr_t is an int, but
|
|
||||||
// on others, it's a long. When AtomicWord and Atomic32 are based on different
|
|
||||||
// fundamental types, their pointers are incompatible.
|
|
||||||
//
|
|
||||||
// This file defines function overloads to allow both AtomicWord and Atomic32
|
|
||||||
// data to be used with this interface.
|
|
||||||
//
|
|
||||||
// On LP64 platforms, AtomicWord and Atomic64 are both always long,
|
|
||||||
// so this problem doesn't occur.
|
|
||||||
|
|
||||||
#if !defined(ARCH_CPU_64_BITS)
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
namespace subtle {
|
|
||||||
|
|
||||||
inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord old_value,
|
|
||||||
AtomicWord new_value) {
|
|
||||||
return NoBarrier_CompareAndSwap(reinterpret_cast<volatile Atomic32*>(ptr),
|
|
||||||
old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord new_value) {
|
|
||||||
return NoBarrier_AtomicExchange(reinterpret_cast<volatile Atomic32*>(ptr),
|
|
||||||
new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord increment) {
|
|
||||||
return NoBarrier_AtomicIncrement(reinterpret_cast<volatile Atomic32*>(ptr),
|
|
||||||
increment);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord increment) {
|
|
||||||
return Barrier_AtomicIncrement(reinterpret_cast<volatile Atomic32*>(ptr),
|
|
||||||
increment);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord old_value,
|
|
||||||
AtomicWord new_value) {
|
|
||||||
return base::subtle::Acquire_CompareAndSwap(
|
|
||||||
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr,
|
|
||||||
AtomicWord old_value,
|
|
||||||
AtomicWord new_value) {
|
|
||||||
return base::subtle::Release_CompareAndSwap(
|
|
||||||
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile AtomicWord* ptr, AtomicWord value) {
|
|
||||||
NoBarrier_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) {
|
|
||||||
return base::subtle::Acquire_Store(reinterpret_cast<volatile Atomic32*>(ptr),
|
|
||||||
value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) {
|
|
||||||
return base::subtle::Release_Store(reinterpret_cast<volatile Atomic32*>(ptr),
|
|
||||||
value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord NoBarrier_Load(volatile const AtomicWord* ptr) {
|
|
||||||
return NoBarrier_Load(reinterpret_cast<volatile const Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) {
|
|
||||||
return base::subtle::Acquire_Load(
|
|
||||||
reinterpret_cast<volatile const Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline AtomicWord Release_Load(volatile const AtomicWord* ptr) {
|
|
||||||
return base::subtle::Release_Load(
|
|
||||||
reinterpret_cast<volatile const Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace base::subtle
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // !defined(ARCH_CPU_64_BITS)
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_ATOMICWORD_COMPAT_H_
|
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
// Copyright (c) 2012 Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// Do not include this header file directly. Use base/cef_atomicops.h
|
|
||||||
// instead.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_
|
|
||||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_
|
|
||||||
|
|
||||||
#include <libkern/OSAtomic.h>
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
namespace subtle {
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 prev_value;
|
|
||||||
do {
|
|
||||||
if (OSAtomicCompareAndSwap32(old_value, new_value,
|
|
||||||
const_cast<Atomic32*>(ptr))) {
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
prev_value = *ptr;
|
|
||||||
} while (prev_value == old_value);
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 old_value;
|
|
||||||
do {
|
|
||||||
old_value = *ptr;
|
|
||||||
} while (!OSAtomicCompareAndSwap32(old_value, new_value,
|
|
||||||
const_cast<Atomic32*>(ptr)));
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
return OSAtomicAdd32(increment, const_cast<Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
return OSAtomicAdd32Barrier(increment, const_cast<Atomic32*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
|
||||||
OSMemoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 prev_value;
|
|
||||||
do {
|
|
||||||
if (OSAtomicCompareAndSwap32Barrier(old_value, new_value,
|
|
||||||
const_cast<Atomic32*>(ptr))) {
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
prev_value = *ptr;
|
|
||||||
} while (prev_value == old_value);
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value;
|
|
||||||
MemoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
MemoryBarrier();
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
|
||||||
Atomic32 value = *ptr;
|
|
||||||
MemoryBarrier();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __LP64__
|
|
||||||
|
|
||||||
// 64-bit implementation on 64-bit platform
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
Atomic64 prev_value;
|
|
||||||
do {
|
|
||||||
if (OSAtomicCompareAndSwap64(old_value, new_value,
|
|
||||||
reinterpret_cast<volatile int64_t*>(ptr))) {
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
prev_value = *ptr;
|
|
||||||
} while (prev_value == old_value);
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
Atomic64 old_value;
|
|
||||||
do {
|
|
||||||
old_value = *ptr;
|
|
||||||
} while (!OSAtomicCompareAndSwap64(old_value, new_value,
|
|
||||||
reinterpret_cast<volatile int64_t*>(ptr)));
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
|
||||||
Atomic64 increment) {
|
|
||||||
return OSAtomicAdd64(increment, reinterpret_cast<volatile int64_t*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
|
||||||
Atomic64 increment) {
|
|
||||||
return OSAtomicAdd64Barrier(increment,
|
|
||||||
reinterpret_cast<volatile int64_t*>(ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
Atomic64 prev_value;
|
|
||||||
do {
|
|
||||||
if (OSAtomicCompareAndSwap64Barrier(
|
|
||||||
old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {
|
|
||||||
return old_value;
|
|
||||||
}
|
|
||||||
prev_value = *ptr;
|
|
||||||
} while (prev_value == old_value);
|
|
||||||
return prev_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
// The lib kern interface does not distinguish between
|
|
||||||
// Acquire and Release memory barriers; they are equivalent.
|
|
||||||
return Acquire_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
*ptr = value;
|
|
||||||
MemoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
MemoryBarrier();
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
|
||||||
Atomic64 value = *ptr;
|
|
||||||
MemoryBarrier();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // defined(__LP64__)
|
|
||||||
|
|
||||||
} // namespace base::subtle
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_
|
|
||||||
@@ -1,268 +0,0 @@
|
|||||||
// Copyright (c) 2011 Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// Do not include this header file directly. Use base/cef_atomicops.h
|
|
||||||
// instead.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_GCC_H_
|
|
||||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_GCC_H_
|
|
||||||
|
|
||||||
// This struct is not part of the public API of this module; clients may not
|
|
||||||
// use it.
|
|
||||||
// Features of this x86. Values may not be correct before main() is run,
|
|
||||||
// but are set conservatively.
|
|
||||||
struct AtomicOps_x86CPUFeatureStruct {
|
|
||||||
bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence
|
|
||||||
// after acquire compare-and-swap.
|
|
||||||
};
|
|
||||||
extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures;
|
|
||||||
|
|
||||||
#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory")
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
namespace subtle {
|
|
||||||
|
|
||||||
// 32-bit low-level operations on any platform.
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 prev;
|
|
||||||
__asm__ __volatile__("lock; cmpxchgl %1,%2"
|
|
||||||
: "=a"(prev)
|
|
||||||
: "q"(new_value), "m"(*ptr), "0"(old_value)
|
|
||||||
: "memory");
|
|
||||||
return prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
__asm__ __volatile__("xchgl %1,%0" // The lock prefix is implicit for xchg.
|
|
||||||
: "=r"(new_value)
|
|
||||||
: "m"(*ptr), "0"(new_value)
|
|
||||||
: "memory");
|
|
||||||
return new_value; // Now it's the previous value.
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
Atomic32 temp = increment;
|
|
||||||
__asm__ __volatile__("lock; xaddl %0,%1"
|
|
||||||
: "+r"(temp), "+m"(*ptr)
|
|
||||||
:
|
|
||||||
: "memory");
|
|
||||||
// temp now holds the old value of *ptr
|
|
||||||
return temp + increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
Atomic32 temp = increment;
|
|
||||||
__asm__ __volatile__("lock; xaddl %0,%1"
|
|
||||||
: "+r"(temp), "+m"(*ptr)
|
|
||||||
:
|
|
||||||
: "memory");
|
|
||||||
// temp now holds the old value of *ptr
|
|
||||||
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
|
||||||
__asm__ __volatile__("lfence" : : : "memory");
|
|
||||||
}
|
|
||||||
return temp + increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
|
||||||
__asm__ __volatile__("lfence" : : : "memory");
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void MemoryBarrier() {
|
|
||||||
__asm__ __volatile__("mfence" : : : "memory");
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value;
|
|
||||||
MemoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
ATOMICOPS_COMPILER_BARRIER();
|
|
||||||
*ptr = value; // An x86 store acts as a release barrier.
|
|
||||||
// See comments in Atomic64 version of Release_Store(), below.
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
|
||||||
Atomic32 value = *ptr; // An x86 load acts as a acquire barrier.
|
|
||||||
// See comments in Atomic64 version of Release_Store(), below.
|
|
||||||
ATOMICOPS_COMPILER_BARRIER();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__x86_64__)
|
|
||||||
|
|
||||||
// 64-bit low-level operations on 64-bit platform.
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
Atomic64 prev;
|
|
||||||
__asm__ __volatile__("lock; cmpxchgq %1,%2"
|
|
||||||
: "=a"(prev)
|
|
||||||
: "q"(new_value), "m"(*ptr), "0"(old_value)
|
|
||||||
: "memory");
|
|
||||||
return prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
__asm__ __volatile__("xchgq %1,%0" // The lock prefix is implicit for xchg.
|
|
||||||
: "=r"(new_value)
|
|
||||||
: "m"(*ptr), "0"(new_value)
|
|
||||||
: "memory");
|
|
||||||
return new_value; // Now it's the previous value.
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
|
||||||
Atomic64 increment) {
|
|
||||||
Atomic64 temp = increment;
|
|
||||||
__asm__ __volatile__("lock; xaddq %0,%1"
|
|
||||||
: "+r"(temp), "+m"(*ptr)
|
|
||||||
:
|
|
||||||
: "memory");
|
|
||||||
// temp now contains the previous value of *ptr
|
|
||||||
return temp + increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
|
||||||
Atomic64 increment) {
|
|
||||||
Atomic64 temp = increment;
|
|
||||||
__asm__ __volatile__("lock; xaddq %0,%1"
|
|
||||||
: "+r"(temp), "+m"(*ptr)
|
|
||||||
:
|
|
||||||
: "memory");
|
|
||||||
// temp now contains the previous value of *ptr
|
|
||||||
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
|
||||||
__asm__ __volatile__("lfence" : : : "memory");
|
|
||||||
}
|
|
||||||
return temp + increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
*ptr = value;
|
|
||||||
MemoryBarrier();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
ATOMICOPS_COMPILER_BARRIER();
|
|
||||||
|
|
||||||
*ptr = value; // An x86 store acts as a release barrier
|
|
||||||
// for current AMD/Intel chips as of Jan 2008.
|
|
||||||
// See also Acquire_Load(), below.
|
|
||||||
|
|
||||||
// When new chips come out, check:
|
|
||||||
// IA-32 Intel Architecture Software Developer's Manual, Volume 3:
|
|
||||||
// System Programming Guide, Chatper 7: Multiple-processor management,
|
|
||||||
// Section 7.2, Memory Ordering.
|
|
||||||
// Last seen at:
|
|
||||||
// http://developer.intel.com/design/pentium4/manuals/index_new.htm
|
|
||||||
//
|
|
||||||
// x86 stores/loads fail to act as barriers for a few instructions (clflush
|
|
||||||
// maskmovdqu maskmovq movntdq movnti movntpd movntps movntq) but these are
|
|
||||||
// not generated by the compiler, and are rare. Users of these instructions
|
|
||||||
// need to know about cache behaviour in any case since all of these involve
|
|
||||||
// either flushing cache lines or non-temporal cache hints.
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
|
||||||
Atomic64 value = *ptr; // An x86 load acts as a acquire barrier,
|
|
||||||
// for current AMD/Intel chips as of Jan 2008.
|
|
||||||
// See also Release_Store(), above.
|
|
||||||
ATOMICOPS_COMPILER_BARRIER();
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
Atomic64 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
|
|
||||||
__asm__ __volatile__("lfence" : : : "memory");
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // defined(__x86_64__)
|
|
||||||
|
|
||||||
} // namespace base::subtle
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#undef ATOMICOPS_COMPILER_BARRIER
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_GCC_H_
|
|
||||||
@@ -1,221 +0,0 @@
|
|||||||
// Copyright (c) 2008 Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// Do not include this header file directly. Use base/cef_atomicops.h
|
|
||||||
// instead.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_MSVC_H_
|
|
||||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_MSVC_H_
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <intrin.h>
|
|
||||||
|
|
||||||
#include "include/base/cef_macros.h"
|
|
||||||
|
|
||||||
#if defined(ARCH_CPU_64_BITS)
|
|
||||||
// windows.h #defines this (only on x64). This causes problems because the
|
|
||||||
// public API also uses MemoryBarrier at the public name for this fence. So, on
|
|
||||||
// X64, undef it, and call its documented
|
|
||||||
// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx)
|
|
||||||
// implementation directly.
|
|
||||||
#undef MemoryBarrier
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
namespace subtle {
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
LONG result = _InterlockedCompareExchange(
|
|
||||||
reinterpret_cast<volatile LONG*>(ptr), static_cast<LONG>(new_value),
|
|
||||||
static_cast<LONG>(old_value));
|
|
||||||
return static_cast<Atomic32>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
LONG result = _InterlockedExchange(reinterpret_cast<volatile LONG*>(ptr),
|
|
||||||
static_cast<LONG>(new_value));
|
|
||||||
return static_cast<Atomic32>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
return _InterlockedExchangeAdd(reinterpret_cast<volatile LONG*>(ptr),
|
|
||||||
static_cast<LONG>(increment)) +
|
|
||||||
increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
|
|
||||||
Atomic32 increment) {
|
|
||||||
return Barrier_AtomicIncrement(ptr, increment);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !(defined(_MSC_VER) && _MSC_VER >= 1400)
|
|
||||||
#error "We require at least vs2005 for MemoryBarrier"
|
|
||||||
#endif
|
|
||||||
inline void MemoryBarrier() {
|
|
||||||
#if defined(ARCH_CPU_64_BITS)
|
|
||||||
// See #undef and note at the top of this file.
|
|
||||||
__faststorefence();
|
|
||||||
#else
|
|
||||||
// We use MemoryBarrier from WinNT.h
|
|
||||||
::MemoryBarrier();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
|
|
||||||
Atomic32 old_value,
|
|
||||||
Atomic32 new_value) {
|
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
NoBarrier_AtomicExchange(ptr, value);
|
|
||||||
// acts as a barrier in this implementation
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
|
|
||||||
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
|
|
||||||
// See comments in Atomic64 version of Release_Store() below.
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
|
|
||||||
Atomic32 value = *ptr;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic32 Release_Load(volatile const Atomic32* ptr) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(_WIN64)
|
|
||||||
|
|
||||||
// 64-bit low-level operations on 64-bit platform.
|
|
||||||
|
|
||||||
COMPILE_ASSERT(sizeof(Atomic64) == sizeof(PVOID), atomic_word_is_atomic);
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
PVOID result = InterlockedCompareExchangePointer(
|
|
||||||
reinterpret_cast<volatile PVOID*>(ptr),
|
|
||||||
reinterpret_cast<PVOID>(new_value), reinterpret_cast<PVOID>(old_value));
|
|
||||||
return reinterpret_cast<Atomic64>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
PVOID result =
|
|
||||||
InterlockedExchangePointer(reinterpret_cast<volatile PVOID*>(ptr),
|
|
||||||
reinterpret_cast<PVOID>(new_value));
|
|
||||||
return reinterpret_cast<Atomic64>(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
|
|
||||||
Atomic64 increment) {
|
|
||||||
return InterlockedExchangeAdd64(reinterpret_cast<volatile LONGLONG*>(ptr),
|
|
||||||
static_cast<LONGLONG>(increment)) +
|
|
||||||
increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
|
|
||||||
Atomic64 increment) {
|
|
||||||
return Barrier_AtomicIncrement(ptr, increment);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
*ptr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
NoBarrier_AtomicExchange(ptr, value);
|
|
||||||
// acts as a barrier in this implementation
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
|
|
||||||
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
|
|
||||||
|
|
||||||
// When new chips come out, check:
|
|
||||||
// IA-32 Intel Architecture Software Developer's Manual, Volume 3:
|
|
||||||
// System Programming Guide, Chatper 7: Multiple-processor management,
|
|
||||||
// Section 7.2, Memory Ordering.
|
|
||||||
// Last seen at:
|
|
||||||
// http://developer.intel.com/design/pentium4/manuals/index_new.htm
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
|
|
||||||
Atomic64 value = *ptr;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
|
|
||||||
MemoryBarrier();
|
|
||||||
return *ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
|
|
||||||
Atomic64 old_value,
|
|
||||||
Atomic64 new_value) {
|
|
||||||
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // defined(_WIN64)
|
|
||||||
|
|
||||||
} // namespace base::subtle
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_X86_MSVC_H_
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,396 +0,0 @@
|
|||||||
// Copyright (c) 2011 Google Inc. All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without
|
|
||||||
// modification, are permitted provided that the following conditions are
|
|
||||||
// met:
|
|
||||||
//
|
|
||||||
// * Redistributions of source code must retain the above copyright
|
|
||||||
// notice, this list of conditions and the following disclaimer.
|
|
||||||
// * Redistributions in binary form must reproduce the above
|
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
|
||||||
// in the documentation and/or other materials provided with the
|
|
||||||
// distribution.
|
|
||||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
|
||||||
// Framework nor the names of its contributors may be used to endorse
|
|
||||||
// or promote products derived from this software without specific prior
|
|
||||||
// written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
// Do not include this header file directly. Use base/cef_bind.h instead.
|
|
||||||
|
|
||||||
// Specializations of RunnableAdapter<> for Windows specific calling
|
|
||||||
// conventions. Please see base/bind_internal.h for more info.
|
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_WIN_H_
|
|
||||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_WIN_H_
|
|
||||||
|
|
||||||
// In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all
|
|
||||||
// the same as __cdecl which would turn the following specializations into
|
|
||||||
// multiple definitions.
|
|
||||||
#if !defined(ARCH_CPU_X86_64)
|
|
||||||
|
|
||||||
namespace base {
|
|
||||||
namespace cef_internal {
|
|
||||||
|
|
||||||
template <typename Functor>
|
|
||||||
class RunnableAdapter;
|
|
||||||
|
|
||||||
// __stdcall Function: Arity 0.
|
|
||||||
template <typename R>
|
|
||||||
class RunnableAdapter<R(__stdcall*)()> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)();
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__stdcall* function)()) : function_(function) {}
|
|
||||||
|
|
||||||
R Run() { return function_(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__stdcall* function_)();
|
|
||||||
};
|
|
||||||
|
|
||||||
// __fastcall Function: Arity 0.
|
|
||||||
template <typename R>
|
|
||||||
class RunnableAdapter<R(__fastcall*)()> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)();
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__fastcall* function)()) : function_(function) {}
|
|
||||||
|
|
||||||
R Run() { return function_(); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__fastcall* function_)();
|
|
||||||
};
|
|
||||||
|
|
||||||
// __stdcall Function: Arity 1.
|
|
||||||
template <typename R, typename A1>
|
|
||||||
class RunnableAdapter<R(__stdcall*)(A1)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__stdcall* function)(A1)) : function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
|
|
||||||
return function_(a1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__stdcall* function_)(A1);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __fastcall Function: Arity 1.
|
|
||||||
template <typename R, typename A1>
|
|
||||||
class RunnableAdapter<R(__fastcall*)(A1)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__fastcall* function)(A1)) : function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
|
|
||||||
return function_(a1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__fastcall* function_)(A1);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __stdcall Function: Arity 2.
|
|
||||||
template <typename R, typename A1, typename A2>
|
|
||||||
class RunnableAdapter<R(__stdcall*)(A1, A2)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__stdcall* function)(A1, A2))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2) {
|
|
||||||
return function_(a1, a2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__stdcall* function_)(A1, A2);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __fastcall Function: Arity 2.
|
|
||||||
template <typename R, typename A1, typename A2>
|
|
||||||
class RunnableAdapter<R(__fastcall*)(A1, A2)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__fastcall* function)(A1, A2))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2) {
|
|
||||||
return function_(a1, a2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__fastcall* function_)(A1, A2);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __stdcall Function: Arity 3.
|
|
||||||
template <typename R, typename A1, typename A2, typename A3>
|
|
||||||
class RunnableAdapter<R(__stdcall*)(A1, A2, A3)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3) {
|
|
||||||
return function_(a1, a2, a3);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__stdcall* function_)(A1, A2, A3);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __fastcall Function: Arity 3.
|
|
||||||
template <typename R, typename A1, typename A2, typename A3>
|
|
||||||
class RunnableAdapter<R(__fastcall*)(A1, A2, A3)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3) {
|
|
||||||
return function_(a1, a2, a3);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__fastcall* function_)(A1, A2, A3);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __stdcall Function: Arity 4.
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4>
|
|
||||||
class RunnableAdapter<R(__stdcall*)(A1, A2, A3, A4)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename CallbackParamTraits<A4>::ForwardType a4) {
|
|
||||||
return function_(a1, a2, a3, a4);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__stdcall* function_)(A1, A2, A3, A4);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __fastcall Function: Arity 4.
|
|
||||||
template <typename R, typename A1, typename A2, typename A3, typename A4>
|
|
||||||
class RunnableAdapter<R(__fastcall*)(A1, A2, A3, A4)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename CallbackParamTraits<A4>::ForwardType a4) {
|
|
||||||
return function_(a1, a2, a3, a4);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__fastcall* function_)(A1, A2, A3, A4);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __stdcall Function: Arity 5.
|
|
||||||
template <typename R,
|
|
||||||
typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5>
|
|
||||||
class RunnableAdapter<R(__stdcall*)(A1, A2, A3, A4, A5)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4, A5);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename CallbackParamTraits<A5>::ForwardType a5) {
|
|
||||||
return function_(a1, a2, a3, a4, a5);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__stdcall* function_)(A1, A2, A3, A4, A5);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __fastcall Function: Arity 5.
|
|
||||||
template <typename R,
|
|
||||||
typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5>
|
|
||||||
class RunnableAdapter<R(__fastcall*)(A1, A2, A3, A4, A5)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4, A5);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename CallbackParamTraits<A5>::ForwardType a5) {
|
|
||||||
return function_(a1, a2, a3, a4, a5);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__fastcall* function_)(A1, A2, A3, A4, A5);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __stdcall Function: Arity 6.
|
|
||||||
template <typename R,
|
|
||||||
typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5,
|
|
||||||
typename A6>
|
|
||||||
class RunnableAdapter<R(__stdcall*)(A1, A2, A3, A4, A5, A6)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4, A5, A6);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5, A6))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename CallbackParamTraits<A5>::ForwardType a5,
|
|
||||||
typename CallbackParamTraits<A6>::ForwardType a6) {
|
|
||||||
return function_(a1, a2, a3, a4, a5, a6);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__stdcall* function_)(A1, A2, A3, A4, A5, A6);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __fastcall Function: Arity 6.
|
|
||||||
template <typename R,
|
|
||||||
typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5,
|
|
||||||
typename A6>
|
|
||||||
class RunnableAdapter<R(__fastcall*)(A1, A2, A3, A4, A5, A6)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4, A5, A6);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5, A6))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename CallbackParamTraits<A5>::ForwardType a5,
|
|
||||||
typename CallbackParamTraits<A6>::ForwardType a6) {
|
|
||||||
return function_(a1, a2, a3, a4, a5, a6);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__fastcall* function_)(A1, A2, A3, A4, A5, A6);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __stdcall Function: Arity 7.
|
|
||||||
template <typename R,
|
|
||||||
typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5,
|
|
||||||
typename A6,
|
|
||||||
typename A7>
|
|
||||||
class RunnableAdapter<R(__stdcall*)(A1, A2, A3, A4, A5, A6, A7)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5, A6, A7))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename CallbackParamTraits<A5>::ForwardType a5,
|
|
||||||
typename CallbackParamTraits<A6>::ForwardType a6,
|
|
||||||
typename CallbackParamTraits<A7>::ForwardType a7) {
|
|
||||||
return function_(a1, a2, a3, a4, a5, a6, a7);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__stdcall* function_)(A1, A2, A3, A4, A5, A6, A7);
|
|
||||||
};
|
|
||||||
|
|
||||||
// __fastcall Function: Arity 7.
|
|
||||||
template <typename R,
|
|
||||||
typename A1,
|
|
||||||
typename A2,
|
|
||||||
typename A3,
|
|
||||||
typename A4,
|
|
||||||
typename A5,
|
|
||||||
typename A6,
|
|
||||||
typename A7>
|
|
||||||
class RunnableAdapter<R(__fastcall*)(A1, A2, A3, A4, A5, A6, A7)> {
|
|
||||||
public:
|
|
||||||
typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
|
|
||||||
|
|
||||||
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5, A6, A7))
|
|
||||||
: function_(function) {}
|
|
||||||
|
|
||||||
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
|
|
||||||
typename CallbackParamTraits<A2>::ForwardType a2,
|
|
||||||
typename CallbackParamTraits<A3>::ForwardType a3,
|
|
||||||
typename CallbackParamTraits<A4>::ForwardType a4,
|
|
||||||
typename CallbackParamTraits<A5>::ForwardType a5,
|
|
||||||
typename CallbackParamTraits<A6>::ForwardType a6,
|
|
||||||
typename CallbackParamTraits<A7>::ForwardType a7) {
|
|
||||||
return function_(a1, a2, a3, a4, a5, a6, a7);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
R(__fastcall* function_)(A1, A2, A3, A4, A5, A6, A7);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace cef_internal
|
|
||||||
} // namespace base
|
|
||||||
|
|
||||||
#endif // !defined(ARCH_CPU_X86_64)
|
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_WIN_H_
|
|
||||||
@@ -36,72 +36,156 @@
|
|||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
||||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
#define CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include "include/base/cef_callback_forward.h"
|
||||||
|
|
||||||
#include "include/base/cef_atomic_ref_count.h"
|
|
||||||
#include "include/base/cef_macros.h"
|
|
||||||
#include "include/base/cef_ref_counted.h"
|
#include "include/base/cef_ref_counted.h"
|
||||||
#include "include/base/cef_scoped_ptr.h"
|
|
||||||
#include "include/base/cef_template_util.h"
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class ScopedVector;
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace cef_internal {
|
|
||||||
class CallbackBase;
|
|
||||||
|
|
||||||
// At the base level, the only task is to add reference counting data. Don't use
|
struct FakeBindState;
|
||||||
// RefCountedThreadSafe since it requires the destructor to be a virtual method.
|
|
||||||
// Creating a vtable for every BindState template instantiation results in a lot
|
namespace cef_internal {
|
||||||
// of bloat. Its only task is to call the destructor which can be done with a
|
|
||||||
// function pointer.
|
class BindStateBase;
|
||||||
class BindStateBase {
|
class FinallyExecutorCommon;
|
||||||
protected:
|
class ThenAndCatchExecutorCommon;
|
||||||
explicit BindStateBase(void (*destructor)(BindStateBase*))
|
|
||||||
: ref_count_(0), destructor_(destructor) {}
|
template <typename ReturnType>
|
||||||
~BindStateBase() {}
|
class PostTaskExecutor;
|
||||||
|
|
||||||
|
template <typename Functor, typename... BoundArgs>
|
||||||
|
struct BindState;
|
||||||
|
|
||||||
|
class CallbackBase;
|
||||||
|
class CallbackBaseCopyable;
|
||||||
|
|
||||||
|
struct BindStateBaseRefCountTraits {
|
||||||
|
static void Destruct(const BindStateBase*);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using PassingType = std::conditional_t<std::is_scalar<T>::value, T, T&&>;
|
||||||
|
|
||||||
|
// BindStateBase is used to provide an opaque handle that the Callback
|
||||||
|
// class can use to represent a function object with bound arguments. It
|
||||||
|
// behaves as an existential type that is used by a corresponding
|
||||||
|
// DoInvoke function to perform the function execution. This allows
|
||||||
|
// us to shield the Callback class from the types of the bound argument via
|
||||||
|
// "type erasure."
|
||||||
|
// At the base level, the only task is to add reference counting data. Avoid
|
||||||
|
// using or inheriting any virtual functions. Creating a vtable for every
|
||||||
|
// BindState template instantiation results in a lot of bloat. Its only task is
|
||||||
|
// to call the destructor which can be done with a function pointer.
|
||||||
|
class BindStateBase
|
||||||
|
: public RefCountedThreadSafe<BindStateBase, BindStateBaseRefCountTraits> {
|
||||||
|
public:
|
||||||
|
REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
|
||||||
|
|
||||||
|
enum CancellationQueryMode {
|
||||||
|
IS_CANCELLED,
|
||||||
|
MAYBE_VALID,
|
||||||
|
};
|
||||||
|
|
||||||
|
using InvokeFuncStorage = void (*)();
|
||||||
|
|
||||||
|
BindStateBase(const BindStateBase&) = delete;
|
||||||
|
BindStateBase& operator=(const BindStateBase&) = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class scoped_refptr<BindStateBase>;
|
BindStateBase(InvokeFuncStorage polymorphic_invoke,
|
||||||
|
void (*destructor)(const BindStateBase*));
|
||||||
|
BindStateBase(InvokeFuncStorage polymorphic_invoke,
|
||||||
|
void (*destructor)(const BindStateBase*),
|
||||||
|
bool (*query_cancellation_traits)(const BindStateBase*,
|
||||||
|
CancellationQueryMode mode));
|
||||||
|
|
||||||
|
~BindStateBase() = default;
|
||||||
|
|
||||||
|
friend struct BindStateBaseRefCountTraits;
|
||||||
|
friend class RefCountedThreadSafe<BindStateBase, BindStateBaseRefCountTraits>;
|
||||||
|
|
||||||
friend class CallbackBase;
|
friend class CallbackBase;
|
||||||
|
friend class CallbackBaseCopyable;
|
||||||
|
|
||||||
void AddRef();
|
// Allowlist subclasses that access the destructor of BindStateBase.
|
||||||
void Release();
|
template <typename Functor, typename... BoundArgs>
|
||||||
|
friend struct BindState;
|
||||||
|
friend struct ::base::FakeBindState;
|
||||||
|
|
||||||
AtomicRefCount ref_count_;
|
bool IsCancelled() const {
|
||||||
|
return query_cancellation_traits_(this, IS_CANCELLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MaybeValid() const {
|
||||||
|
return query_cancellation_traits_(this, MAYBE_VALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// In C++, it is safe to cast function pointers to function pointers of
|
||||||
|
// another type. It is not okay to use void*. We create a InvokeFuncStorage
|
||||||
|
// that that can store our function pointer, and then cast it back to
|
||||||
|
// the original type on usage.
|
||||||
|
InvokeFuncStorage polymorphic_invoke_;
|
||||||
|
|
||||||
// Pointer to a function that will properly destroy |this|.
|
// Pointer to a function that will properly destroy |this|.
|
||||||
void (*destructor_)(BindStateBase*);
|
void (*destructor_)(const BindStateBase*);
|
||||||
|
bool (*query_cancellation_traits_)(const BindStateBase*,
|
||||||
DISALLOW_COPY_AND_ASSIGN(BindStateBase);
|
CancellationQueryMode mode);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Holds the Callback methods that don't require specialization to reduce
|
// Holds the Callback methods that don't require specialization to reduce
|
||||||
// template bloat.
|
// template bloat.
|
||||||
|
// CallbackBase<MoveOnly> is a direct base class of MoveOnly callbacks, and
|
||||||
|
// CallbackBase<Copyable> uses CallbackBase<MoveOnly> for its implementation.
|
||||||
class CallbackBase {
|
class CallbackBase {
|
||||||
public:
|
public:
|
||||||
|
inline CallbackBase(CallbackBase&& c) noexcept;
|
||||||
|
CallbackBase& operator=(CallbackBase&& c) noexcept;
|
||||||
|
|
||||||
|
explicit CallbackBase(const CallbackBaseCopyable& c);
|
||||||
|
CallbackBase& operator=(const CallbackBaseCopyable& c);
|
||||||
|
|
||||||
|
explicit CallbackBase(CallbackBaseCopyable&& c) noexcept;
|
||||||
|
CallbackBase& operator=(CallbackBaseCopyable&& c) noexcept;
|
||||||
|
|
||||||
// Returns true if Callback is null (doesn't refer to anything).
|
// Returns true if Callback is null (doesn't refer to anything).
|
||||||
bool is_null() const { return bind_state_.get() == NULL; }
|
bool is_null() const { return !bind_state_; }
|
||||||
|
explicit operator bool() const { return !is_null(); }
|
||||||
|
|
||||||
|
// Returns true if the callback invocation will be nop due to an cancellation.
|
||||||
|
// It's invalid to call this on uninitialized callback.
|
||||||
|
//
|
||||||
|
// Must be called on the Callback's destination sequence.
|
||||||
|
bool IsCancelled() const;
|
||||||
|
|
||||||
|
// If this returns false, the callback invocation will be a nop due to a
|
||||||
|
// cancellation. This may(!) still return true, even on a cancelled callback.
|
||||||
|
//
|
||||||
|
// This function is thread-safe.
|
||||||
|
bool MaybeValid() const;
|
||||||
|
|
||||||
// Returns the Callback into an uninitialized state.
|
// Returns the Callback into an uninitialized state.
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// In C++, it is safe to cast function pointers to function pointers of
|
friend class FinallyExecutorCommon;
|
||||||
// another type. It is not okay to use void*. We create a InvokeFuncStorage
|
friend class ThenAndCatchExecutorCommon;
|
||||||
// that that can store our function pointer, and then cast it back to
|
|
||||||
// the original type on usage.
|
template <typename ReturnType>
|
||||||
typedef void (*InvokeFuncStorage)(void);
|
friend class PostTaskExecutor;
|
||||||
|
|
||||||
|
using InvokeFuncStorage = BindStateBase::InvokeFuncStorage;
|
||||||
|
|
||||||
// Returns true if this callback equals |other|. |other| may be null.
|
// Returns true if this callback equals |other|. |other| may be null.
|
||||||
bool Equals(const CallbackBase& other) const;
|
bool EqualsInternal(const CallbackBase& other) const;
|
||||||
|
|
||||||
|
constexpr inline CallbackBase();
|
||||||
|
|
||||||
// Allow initializing of |bind_state_| via the constructor to avoid default
|
// Allow initializing of |bind_state_| via the constructor to avoid default
|
||||||
// initialization of the scoped_refptr. We do not also initialize
|
// initialization of the scoped_refptr.
|
||||||
// |polymorphic_invoke_| here because doing a normal assignment in the
|
explicit inline CallbackBase(BindStateBase* bind_state);
|
||||||
// derived Callback templates makes for much nicer compiler errors.
|
|
||||||
explicit CallbackBase(BindStateBase* bind_state);
|
InvokeFuncStorage polymorphic_invoke() const {
|
||||||
|
return bind_state_->polymorphic_invoke_;
|
||||||
|
}
|
||||||
|
|
||||||
// Force the destructor to be instantiated inside this translation unit so
|
// Force the destructor to be instantiated inside this translation unit so
|
||||||
// that our subclasses will not get inlined versions. Avoids more template
|
// that our subclasses will not get inlined versions. Avoids more template
|
||||||
@@ -109,115 +193,82 @@ class CallbackBase {
|
|||||||
~CallbackBase();
|
~CallbackBase();
|
||||||
|
|
||||||
scoped_refptr<BindStateBase> bind_state_;
|
scoped_refptr<BindStateBase> bind_state_;
|
||||||
InvokeFuncStorage polymorphic_invoke_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// A helper template to determine if given type is non-const move-only-type,
|
constexpr CallbackBase::CallbackBase() = default;
|
||||||
// i.e. if a value of the given type should be passed via .Pass() in a
|
CallbackBase::CallbackBase(CallbackBase&&) noexcept = default;
|
||||||
// destructive way.
|
CallbackBase::CallbackBase(BindStateBase* bind_state)
|
||||||
template <typename T>
|
: bind_state_(AdoptRef(bind_state)) {}
|
||||||
struct IsMoveOnlyType {
|
|
||||||
template <typename U>
|
|
||||||
static YesType Test(const typename U::MoveOnlyTypeForCPP03*);
|
|
||||||
|
|
||||||
template <typename U>
|
// CallbackBase<Copyable> is a direct base class of Copyable Callbacks.
|
||||||
static NoType Test(...);
|
class CallbackBaseCopyable : public CallbackBase {
|
||||||
|
public:
|
||||||
|
CallbackBaseCopyable(const CallbackBaseCopyable& c);
|
||||||
|
CallbackBaseCopyable(CallbackBaseCopyable&& c) noexcept = default;
|
||||||
|
CallbackBaseCopyable& operator=(const CallbackBaseCopyable& c);
|
||||||
|
CallbackBaseCopyable& operator=(CallbackBaseCopyable&& c) noexcept;
|
||||||
|
|
||||||
static const bool value =
|
protected:
|
||||||
sizeof(Test<T>(0)) == sizeof(YesType) && !is_const<T>::value;
|
constexpr CallbackBaseCopyable() = default;
|
||||||
|
explicit CallbackBaseCopyable(BindStateBase* bind_state)
|
||||||
|
: CallbackBase(bind_state) {}
|
||||||
|
~CallbackBaseCopyable() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is a typetraits object that's used to take an argument type, and
|
// Helpers for the `Then()` implementation.
|
||||||
// extract a suitable type for storing and forwarding arguments.
|
template <typename OriginalCallback, typename ThenCallback>
|
||||||
//
|
struct ThenHelper;
|
||||||
// In particular, it strips off references, and converts arrays to
|
|
||||||
// pointers for storage; and it avoids accidentally trying to create a
|
// Specialization when original callback returns `void`.
|
||||||
// "reference of a reference" if the argument is a reference type.
|
template <template <typename> class OriginalCallback,
|
||||||
//
|
template <typename>
|
||||||
// This array type becomes an issue for storage because we are passing bound
|
class ThenCallback,
|
||||||
// parameters by const reference. In this case, we end up passing an actual
|
typename... OriginalArgs,
|
||||||
// array type in the initializer list which C++ does not allow. This will
|
typename ThenR,
|
||||||
// break passing of C-string literals.
|
typename... ThenArgs>
|
||||||
template <typename T, bool is_move_only = IsMoveOnlyType<T>::value>
|
struct ThenHelper<OriginalCallback<void(OriginalArgs...)>,
|
||||||
struct CallbackParamTraits {
|
ThenCallback<ThenR(ThenArgs...)>> {
|
||||||
typedef const T& ForwardType;
|
static_assert(sizeof...(ThenArgs) == 0,
|
||||||
typedef T StorageType;
|
"|then| callback cannot accept parameters if |this| has a "
|
||||||
|
"void return type.");
|
||||||
|
|
||||||
|
static auto CreateTrampoline() {
|
||||||
|
return [](OriginalCallback<void(OriginalArgs...)> c1,
|
||||||
|
ThenCallback<ThenR(ThenArgs...)> c2, OriginalArgs... c1_args) {
|
||||||
|
std::move(c1).Run(std::forward<OriginalArgs>(c1_args)...);
|
||||||
|
return std::move(c2).Run();
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// The Storage should almost be impossible to trigger unless someone manually
|
// Specialization when original callback returns a non-void type.
|
||||||
// specifies type of the bind parameters. However, in case they do,
|
template <template <typename> class OriginalCallback,
|
||||||
// this will guard against us accidentally storing a reference parameter.
|
template <typename>
|
||||||
//
|
class ThenCallback,
|
||||||
// The ForwardType should only be used for unbound arguments.
|
typename OriginalR,
|
||||||
template <typename T>
|
typename... OriginalArgs,
|
||||||
struct CallbackParamTraits<T&, false> {
|
typename ThenR,
|
||||||
typedef T& ForwardType;
|
typename... ThenArgs>
|
||||||
typedef T StorageType;
|
struct ThenHelper<OriginalCallback<OriginalR(OriginalArgs...)>,
|
||||||
|
ThenCallback<ThenR(ThenArgs...)>> {
|
||||||
|
static_assert(sizeof...(ThenArgs) == 1,
|
||||||
|
"|then| callback must accept exactly one parameter if |this| "
|
||||||
|
"has a non-void return type.");
|
||||||
|
// TODO(dcheng): This should probably check is_convertible as well (same with
|
||||||
|
// `AssertBindArgsValidity`).
|
||||||
|
static_assert(std::is_constructible<ThenArgs..., OriginalR&&>::value,
|
||||||
|
"|then| callback's parameter must be constructible from "
|
||||||
|
"return type of |this|.");
|
||||||
|
|
||||||
|
static auto CreateTrampoline() {
|
||||||
|
return [](OriginalCallback<OriginalR(OriginalArgs...)> c1,
|
||||||
|
ThenCallback<ThenR(ThenArgs...)> c2, OriginalArgs... c1_args) {
|
||||||
|
return std::move(c2).Run(
|
||||||
|
std::move(c1).Run(std::forward<OriginalArgs>(c1_args)...));
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note that for array types, we implicitly add a const in the conversion. This
|
|
||||||
// means that it is not possible to bind array arguments to functions that take
|
|
||||||
// a non-const pointer. Trying to specialize the template based on a "const
|
|
||||||
// T[n]" does not seem to match correctly, so we are stuck with this
|
|
||||||
// restriction.
|
|
||||||
template <typename T, size_t n>
|
|
||||||
struct CallbackParamTraits<T[n], false> {
|
|
||||||
typedef const T* ForwardType;
|
|
||||||
typedef const T* StorageType;
|
|
||||||
};
|
|
||||||
|
|
||||||
// See comment for CallbackParamTraits<T[n]>.
|
|
||||||
template <typename T>
|
|
||||||
struct CallbackParamTraits<T[], false> {
|
|
||||||
typedef const T* ForwardType;
|
|
||||||
typedef const T* StorageType;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Parameter traits for movable-but-not-copyable scopers.
|
|
||||||
//
|
|
||||||
// Callback<>/Bind() understands movable-but-not-copyable semantics where
|
|
||||||
// the type cannot be copied but can still have its state destructively
|
|
||||||
// transferred (aka. moved) to another instance of the same type by calling a
|
|
||||||
// helper function. When used with Bind(), this signifies transferal of the
|
|
||||||
// object's state to the target function.
|
|
||||||
//
|
|
||||||
// For these types, the ForwardType must not be a const reference, or a
|
|
||||||
// reference. A const reference is inappropriate, and would break const
|
|
||||||
// correctness, because we are implementing a destructive move. A non-const
|
|
||||||
// reference cannot be used with temporaries which means the result of a
|
|
||||||
// function or a cast would not be usable with Callback<> or Bind().
|
|
||||||
template <typename T>
|
|
||||||
struct CallbackParamTraits<T, true> {
|
|
||||||
typedef T ForwardType;
|
|
||||||
typedef T StorageType;
|
|
||||||
};
|
|
||||||
|
|
||||||
// CallbackForward() is a very limited simulation of C++11's std::forward()
|
|
||||||
// used by the Callback/Bind system for a set of movable-but-not-copyable
|
|
||||||
// types. It is needed because forwarding a movable-but-not-copyable
|
|
||||||
// argument to another function requires us to invoke the proper move
|
|
||||||
// operator to create a rvalue version of the type. The supported types are
|
|
||||||
// whitelisted below as overloads of the CallbackForward() function. The
|
|
||||||
// default template compiles out to be a no-op.
|
|
||||||
//
|
|
||||||
// In C++11, std::forward would replace all uses of this function. However, it
|
|
||||||
// is impossible to implement a general std::forward with C++11 due to a lack
|
|
||||||
// of rvalue references.
|
|
||||||
//
|
|
||||||
// In addition to Callback/Bind, this is used by PostTaskAndReplyWithResult to
|
|
||||||
// simulate std::forward() and forward the result of one Callback as a
|
|
||||||
// parameter to another callback. This is to support Callbacks that return
|
|
||||||
// the movable-but-not-copyable types whitelisted above.
|
|
||||||
template <typename T>
|
|
||||||
typename enable_if<!IsMoveOnlyType<T>::value, T>::type& CallbackForward(T& t) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
typename enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward(T& t) {
|
|
||||||
return t.Pass();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace cef_internal
|
} // namespace cef_internal
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
||||||
|
|||||||
50
include/base/internal/cef_color_id_macros.inc
Normal file
50
include/base/internal/cef_color_id_macros.inc
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// Copyright 2019 The Chromium Authors
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
// The following macros are used to declare both the color id enumerations and
|
||||||
|
// the stringized names of the enumeration elements for use in dump_colors. To
|
||||||
|
// stringize the element names, define STRINGIZE_COLOR_IDS prior to including
|
||||||
|
// this file. This file is intended to be included just before and just after
|
||||||
|
// the enumeration or string array declarations.
|
||||||
|
|
||||||
|
#if !defined(COLOR_ID_MACROS_DEFINED)
|
||||||
|
#define COLOR_ID_MACROS_DEFINED
|
||||||
|
#if defined(STRINGIZE_COLOR_IDS)
|
||||||
|
// Convert first token to string, throw away the rest.
|
||||||
|
#define D1(enum_name) #enum_name
|
||||||
|
#define D2(enum_name, enum_value) #enum_name
|
||||||
|
#else // defined(STRINGIZE_COLOR_IDS)
|
||||||
|
// Declare enum with optional assigned value.
|
||||||
|
#define D1(enum_name) enum_name
|
||||||
|
#define D2(enum_name, enum_value) enum_name = enum_value
|
||||||
|
#endif // defined(STRINGIZE_COLOR_IDS)
|
||||||
|
// Select which token in the declaration is the assigned value.
|
||||||
|
// Use first and optional third token, ignore optional second.
|
||||||
|
#define E1(enum_name) D1(enum_name)
|
||||||
|
#define E2(enum_name, old_enum_name) D1(enum_name)
|
||||||
|
#define E3(enum_name, old_enum_name, enum_value) D2(enum_name, enum_value)
|
||||||
|
#define GET_E(_1, _2, _3, macro_name, ...) macro_name
|
||||||
|
#if defined(COMPILER_MSVC)
|
||||||
|
// Workaround for MSVC not properly expanding __VA_ARGS__.
|
||||||
|
#define EXPAND(x) x
|
||||||
|
#define E_CPONLY(...) EXPAND(E(__VA_ARGS__))
|
||||||
|
#define E(...) EXPAND(GET_E(__VA_ARGS__, E3, E2, E1)(__VA_ARGS__)),
|
||||||
|
#else // !defined(COMPILER_MSVC)
|
||||||
|
#define E_CPONLY(...) E(__VA_ARGS__)
|
||||||
|
#define E(...) GET_E(__VA_ARGS__, E3, E2, E1)(__VA_ARGS__),
|
||||||
|
#endif // !defined(COMPILER_MSVC)
|
||||||
|
#else // !defined(COLOR_ID_MACROS_DEFINED)
|
||||||
|
#undef D1
|
||||||
|
#undef D2
|
||||||
|
#undef E1
|
||||||
|
#undef E2
|
||||||
|
#undef E3
|
||||||
|
#if defined(COMPILER_MSVC)
|
||||||
|
#undef EXPAND
|
||||||
|
#endif
|
||||||
|
#undef E_CPONLY
|
||||||
|
#undef GET_E
|
||||||
|
#undef E
|
||||||
|
#undef COLOR_ID_MACROS_DEFINED
|
||||||
|
#endif // !defined(COLOR_ID_MACROS_DEFINED)
|
||||||
@@ -40,8 +40,6 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "include/base/cef_macros.h"
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace cef_internal {
|
namespace cef_internal {
|
||||||
|
|
||||||
@@ -57,6 +55,10 @@ class LockImpl {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
LockImpl();
|
LockImpl();
|
||||||
|
|
||||||
|
LockImpl(const LockImpl&) = delete;
|
||||||
|
LockImpl& operator=(const LockImpl&) = delete;
|
||||||
|
|
||||||
~LockImpl();
|
~LockImpl();
|
||||||
|
|
||||||
// If the lock is not held, take it and return true. If the lock is already
|
// If the lock is not held, take it and return true. If the lock is already
|
||||||
@@ -77,8 +79,6 @@ class LockImpl {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
NativeHandle native_handle_;
|
NativeHandle native_handle_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(LockImpl);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cef_internal
|
} // namespace cef_internal
|
||||||
|
|||||||
8
include/base/internal/cef_net_error_list.h
Normal file
8
include/base/internal/cef_net_error_list.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2019 The Chromium Embedded Framework 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 net error codes from the Chromium source location. When creating a
|
||||||
|
// CEF binary distribution this file will be replaced with the Chromium version.
|
||||||
|
|
||||||
|
#include "net/base/net_error_list.h"
|
||||||
@@ -32,10 +32,7 @@
|
|||||||
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
||||||
#define CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
#define CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_
|
||||||
|
|
||||||
#include "include/base/cef_build.h"
|
#include <type_traits>
|
||||||
#include "include/base/cef_ref_counted.h"
|
|
||||||
#include "include/base/cef_template_util.h"
|
|
||||||
#include "include/base/cef_tuple.h"
|
|
||||||
|
|
||||||
// It is dangerous to post a task with a T* argument where T is a subtype of
|
// It is dangerous to post a task with a T* argument where T is a subtype of
|
||||||
// RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the
|
// RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the
|
||||||
@@ -46,132 +43,27 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
|
// This is a base internal implementation file used by task.h and callback.h.
|
||||||
|
// Not for public consumption, so we wrap it in namespace internal.
|
||||||
namespace cef_internal {
|
namespace cef_internal {
|
||||||
|
|
||||||
|
template <typename T, typename = void>
|
||||||
|
struct IsRefCountedType : std::false_type {};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct NeedsScopedRefptrButGetsRawPtr {
|
struct IsRefCountedType<T,
|
||||||
#if defined(OS_WIN)
|
std::void_t<decltype(std::declval<T*>()->AddRef()),
|
||||||
enum { value = base::false_type::value };
|
decltype(std::declval<T*>()->Release())>>
|
||||||
#else
|
: std::true_type {};
|
||||||
enum {
|
|
||||||
// Human readable translation: you needed to be a scoped_refptr if you are a
|
|
||||||
// raw pointer type and are convertible to a RefCounted(Base|ThreadSafeBase)
|
|
||||||
// type.
|
|
||||||
value = (is_pointer<T>::value &&
|
|
||||||
(is_convertible<T, subtle::RefCountedBase*>::value ||
|
|
||||||
is_convertible<T, subtle::RefCountedThreadSafeBase*>::value))
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Params>
|
// Human readable translation: you needed to be a scoped_refptr if you are a raw
|
||||||
struct ParamsUseScopedRefptrCorrectly {
|
// pointer type and are convertible to a RefCounted(Base|ThreadSafeBase) type.
|
||||||
enum { value = 0 };
|
template <typename T>
|
||||||
};
|
struct NeedsScopedRefptrButGetsRawPtr
|
||||||
|
: std::conjunction<std::is_pointer<T>,
|
||||||
template <>
|
IsRefCountedType<std::remove_pointer_t<T>>> {
|
||||||
struct ParamsUseScopedRefptrCorrectly<Tuple0> {
|
static_assert(!std::is_reference<T>::value,
|
||||||
enum { value = 1 };
|
"NeedsScopedRefptrButGetsRawPtr requires non-reference type.");
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A>
|
|
||||||
struct ParamsUseScopedRefptrCorrectly<Tuple1<A>> {
|
|
||||||
enum { value = !NeedsScopedRefptrButGetsRawPtr<A>::value };
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A, typename B>
|
|
||||||
struct ParamsUseScopedRefptrCorrectly<Tuple2<A, B>> {
|
|
||||||
enum {
|
|
||||||
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<B>::value)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A, typename B, typename C>
|
|
||||||
struct ParamsUseScopedRefptrCorrectly<Tuple3<A, B, C>> {
|
|
||||||
enum {
|
|
||||||
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<C>::value)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A, typename B, typename C, typename D>
|
|
||||||
struct ParamsUseScopedRefptrCorrectly<Tuple4<A, B, C, D>> {
|
|
||||||
enum {
|
|
||||||
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<D>::value)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A, typename B, typename C, typename D, typename E>
|
|
||||||
struct ParamsUseScopedRefptrCorrectly<Tuple5<A, B, C, D, E>> {
|
|
||||||
enum {
|
|
||||||
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<E>::value)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A,
|
|
||||||
typename B,
|
|
||||||
typename C,
|
|
||||||
typename D,
|
|
||||||
typename E,
|
|
||||||
typename F>
|
|
||||||
struct ParamsUseScopedRefptrCorrectly<Tuple6<A, B, C, D, E, F>> {
|
|
||||||
enum {
|
|
||||||
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<E>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<F>::value)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A,
|
|
||||||
typename B,
|
|
||||||
typename C,
|
|
||||||
typename D,
|
|
||||||
typename E,
|
|
||||||
typename F,
|
|
||||||
typename G>
|
|
||||||
struct ParamsUseScopedRefptrCorrectly<Tuple7<A, B, C, D, E, F, G>> {
|
|
||||||
enum {
|
|
||||||
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<E>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<F>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<G>::value)
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename A,
|
|
||||||
typename B,
|
|
||||||
typename C,
|
|
||||||
typename D,
|
|
||||||
typename E,
|
|
||||||
typename F,
|
|
||||||
typename G,
|
|
||||||
typename H>
|
|
||||||
struct ParamsUseScopedRefptrCorrectly<Tuple8<A, B, C, D, E, F, G, H>> {
|
|
||||||
enum {
|
|
||||||
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<E>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<F>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<G>::value ||
|
|
||||||
NeedsScopedRefptrButGetsRawPtr<H>::value)
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cef_internal
|
} // namespace cef_internal
|
||||||
|
|||||||
67
include/base/internal/cef_scoped_block_mac.h
Normal file
67
include/base/internal/cef_scoped_block_mac.h
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
// Copyright (c) 2013 Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
// Do not include this header file directly. Use base/mac/scoped_block.h
|
||||||
|
// instead.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_BLOCK_MAC_H_
|
||||||
|
#define CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_BLOCK_MAC_H_
|
||||||
|
|
||||||
|
#include <Block.h>
|
||||||
|
|
||||||
|
#include "include/base/cef_scoped_typeref_mac.h"
|
||||||
|
|
||||||
|
#if defined(__has_feature) && __has_feature(objc_arc)
|
||||||
|
#error \
|
||||||
|
"Cannot include include/base/internal/cef_scoped_block_mac.h in file built with ARC."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
namespace mac {
|
||||||
|
|
||||||
|
namespace cef_internal {
|
||||||
|
|
||||||
|
template <typename B>
|
||||||
|
struct ScopedBlockTraits {
|
||||||
|
static B InvalidValue() { return nullptr; }
|
||||||
|
static B Retain(B block) { return Block_copy(block); }
|
||||||
|
static void Release(B block) { Block_release(block); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cef_internal
|
||||||
|
|
||||||
|
// ScopedBlock<> is patterned after ScopedCFTypeRef<>, but uses Block_copy() and
|
||||||
|
// Block_release() instead of CFRetain() and CFRelease().
|
||||||
|
template <typename B>
|
||||||
|
using ScopedBlock = ScopedTypeRef<B, cef_internal::ScopedBlockTraits<B>>;
|
||||||
|
|
||||||
|
} // namespace mac
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_BLOCK_MAC_H_
|
||||||
53
include/base/internal/cef_scoped_policy.h
Normal file
53
include/base/internal/cef_scoped_policy.h
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
// Copyright (c) 2012 Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
// Do not include this header file directly. Use base/memory/scoped_policy.h
|
||||||
|
// instead.
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_POLICY_H_
|
||||||
|
#define CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_POLICY_H_
|
||||||
|
|
||||||
|
namespace base {
|
||||||
|
namespace scoped_policy {
|
||||||
|
|
||||||
|
// Defines the ownership policy for a scoped object.
|
||||||
|
enum OwnershipPolicy {
|
||||||
|
// The scoped object takes ownership of an object by taking over an existing
|
||||||
|
// ownership claim.
|
||||||
|
ASSUME,
|
||||||
|
|
||||||
|
// The scoped object will retain the object and any initial ownership is
|
||||||
|
// not changed.
|
||||||
|
RETAIN
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace scoped_policy
|
||||||
|
} // namespace base
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_SCOPED_POLICY_H_
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=05029efef860f52da671d55b0afa3df43e016045$
|
// $hash=32279f653514bd05dea3d5d8e6b852530a90ee2e$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_ACCESSIBILITY_HANDLER_CAPI_H_
|
||||||
@@ -47,27 +47,27 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to receive accessibility notification when
|
/// Implement this structure to receive accessibility notification when
|
||||||
// accessibility events have been registered. The functions of this structure
|
/// accessibility events have been registered. The functions of this structure
|
||||||
// will be called on the UI thread.
|
/// will be called on the UI thread.
|
||||||
///
|
///
|
||||||
typedef struct _cef_accessibility_handler_t {
|
typedef struct _cef_accessibility_handler_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called after renderer process sends accessibility tree changes to the
|
/// Called after renderer process sends accessibility tree changes to the
|
||||||
// browser process.
|
/// browser process.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_accessibility_tree_change)(
|
void(CEF_CALLBACK* on_accessibility_tree_change)(
|
||||||
struct _cef_accessibility_handler_t* self,
|
struct _cef_accessibility_handler_t* self,
|
||||||
struct _cef_value_t* value);
|
struct _cef_value_t* value);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called after renderer process sends accessibility location changes to the
|
/// Called after renderer process sends accessibility location changes to the
|
||||||
// browser process.
|
/// browser process.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_accessibility_location_change)(
|
void(CEF_CALLBACK* on_accessibility_location_change)(
|
||||||
struct _cef_accessibility_handler_t* self,
|
struct _cef_accessibility_handler_t* self,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=a386eaf81574ae85a4f522afd4287742f778e78d$
|
// $hash=a2deeda24cb730b4e212514fde833414b450559d$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_APP_CAPI_H_
|
||||||
@@ -54,25 +54,26 @@ extern "C" {
|
|||||||
struct _cef_app_t;
|
struct _cef_app_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to provide handler implementations. Methods will be
|
/// Implement this structure to provide handler implementations. Methods will be
|
||||||
// called by the process and/or thread indicated.
|
/// called by the process and/or thread indicated.
|
||||||
///
|
///
|
||||||
typedef struct _cef_app_t {
|
typedef struct _cef_app_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Provides an opportunity to view and/or modify command-line arguments before
|
/// Provides an opportunity to view and/or modify command-line arguments
|
||||||
// processing by CEF and Chromium. The |process_type| value will be NULL for
|
/// before processing by CEF and Chromium. The |process_type| value will be
|
||||||
// the browser process. Do not keep a reference to the cef_command_line_t
|
/// NULL for the browser process. Do not keep a reference to the
|
||||||
// object passed to this function. The CefSettings.command_line_args_disabled
|
/// cef_command_line_t object passed to this function. The
|
||||||
// value can be used to start with an NULL command-line object. Any values
|
/// cef_settings_t.command_line_args_disabled value can be used to start with
|
||||||
// specified in CefSettings that equate to command-line arguments will be set
|
/// an NULL command-line object. Any values specified in CefSettings that
|
||||||
// before this function is called. Be cautious when using this function to
|
/// equate to command-line arguments will be set before this function is
|
||||||
// modify command-line arguments for non-browser processes as this may result
|
/// called. Be cautious when using this function to modify command-line
|
||||||
// in undefined behavior including crashes.
|
/// arguments for non-browser processes as this may result in undefined
|
||||||
|
/// behavior including crashes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_before_command_line_processing)(
|
void(CEF_CALLBACK* on_before_command_line_processing)(
|
||||||
struct _cef_app_t* self,
|
struct _cef_app_t* self,
|
||||||
@@ -80,119 +81,120 @@ typedef struct _cef_app_t {
|
|||||||
struct _cef_command_line_t* command_line);
|
struct _cef_command_line_t* command_line);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Provides an opportunity to register custom schemes. Do not keep a reference
|
/// Provides an opportunity to register custom schemes. Do not keep a
|
||||||
// to the |registrar| object. This function is called on the main thread for
|
/// reference to the |registrar| object. This function is called on the main
|
||||||
// each process and the registered schemes should be the same across all
|
/// thread for each process and the registered schemes should be the same
|
||||||
// processes.
|
/// across all processes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_register_custom_schemes)(
|
void(CEF_CALLBACK* on_register_custom_schemes)(
|
||||||
struct _cef_app_t* self,
|
struct _cef_app_t* self,
|
||||||
struct _cef_scheme_registrar_t* registrar);
|
struct _cef_scheme_registrar_t* registrar);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for resource bundle events. If
|
/// Return the handler for resource bundle events. If no handler is returned
|
||||||
// CefSettings.pack_loading_disabled is true (1) a handler must be returned.
|
/// resources will be loaded from pack files. This function is called by the
|
||||||
// If no handler is returned resources will be loaded from pack files. This
|
/// browser and render processes on multiple threads.
|
||||||
// function is called by the browser and render processes on multiple threads.
|
|
||||||
///
|
///
|
||||||
struct _cef_resource_bundle_handler_t*(
|
struct _cef_resource_bundle_handler_t*(
|
||||||
CEF_CALLBACK* get_resource_bundle_handler)(struct _cef_app_t* self);
|
CEF_CALLBACK* get_resource_bundle_handler)(struct _cef_app_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for functionality specific to the browser process. This
|
/// Return the handler for functionality specific to the browser process. This
|
||||||
// function is called on multiple threads in the browser process.
|
/// function is called on multiple threads in the browser process.
|
||||||
///
|
///
|
||||||
struct _cef_browser_process_handler_t*(
|
struct _cef_browser_process_handler_t*(
|
||||||
CEF_CALLBACK* get_browser_process_handler)(struct _cef_app_t* self);
|
CEF_CALLBACK* get_browser_process_handler)(struct _cef_app_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for functionality specific to the render process. This
|
/// Return the handler for functionality specific to the render process. This
|
||||||
// function is called on the render process main thread.
|
/// function is called on the render process main thread.
|
||||||
///
|
///
|
||||||
struct _cef_render_process_handler_t*(
|
struct _cef_render_process_handler_t*(
|
||||||
CEF_CALLBACK* get_render_process_handler)(struct _cef_app_t* self);
|
CEF_CALLBACK* get_render_process_handler)(struct _cef_app_t* self);
|
||||||
} cef_app_t;
|
} cef_app_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// This function should be called from the application entry point function to
|
/// This function should be called from the application entry point function to
|
||||||
// execute a secondary process. It can be used to run secondary processes from
|
/// execute a secondary process. It can be used to run secondary processes from
|
||||||
// the browser client executable (default behavior) or from a separate
|
/// the browser client executable (default behavior) or from a separate
|
||||||
// executable specified by the CefSettings.browser_subprocess_path value. If
|
/// executable specified by the cef_settings_t.browser_subprocess_path value. If
|
||||||
// called for the browser process (identified by no "type" command-line value)
|
/// called for the browser process (identified by no "type" command-line value)
|
||||||
// it will return immediately with a value of -1. If called for a recognized
|
/// it will return immediately with a value of -1. If called for a recognized
|
||||||
// secondary process it will block until the process should exit and then return
|
/// secondary process it will block until the process should exit and then
|
||||||
// the process exit code. The |application| parameter may be NULL. The
|
/// return the process exit code. The |application| parameter may be NULL. The
|
||||||
// |windows_sandbox_info| parameter is only used on Windows and may be NULL (see
|
/// |windows_sandbox_info| parameter is only used on Windows and may be NULL
|
||||||
// cef_sandbox_win.h for details).
|
/// (see cef_sandbox_win.h for details).
|
||||||
///
|
///
|
||||||
CEF_EXPORT int cef_execute_process(const struct _cef_main_args_t* args,
|
CEF_EXPORT int cef_execute_process(const cef_main_args_t* args,
|
||||||
cef_app_t* application,
|
cef_app_t* application,
|
||||||
void* windows_sandbox_info);
|
void* windows_sandbox_info);
|
||||||
|
|
||||||
///
|
///
|
||||||
// This function should be called on the main application thread to initialize
|
/// This function should be called on the main application thread to initialize
|
||||||
// the CEF browser process. The |application| parameter may be NULL. A return
|
/// the CEF browser process. The |application| parameter may be NULL. Returns
|
||||||
// value of true (1) indicates that it succeeded and false (0) indicates that it
|
/// true (1) if initialization succeeds. Returns false (0) if initialization
|
||||||
// failed. The |windows_sandbox_info| parameter is only used on Windows and may
|
/// fails or if early exit is desired (for example, due to process singleton
|
||||||
// be NULL (see cef_sandbox_win.h for details).
|
/// relaunch behavior). If this function returns false (0) then the application
|
||||||
|
/// should exit immediately without calling any other CEF functions except,
|
||||||
|
/// optionally, CefGetErrorCode. The |windows_sandbox_info| parameter is only
|
||||||
|
/// used on Windows and may be NULL (see cef_sandbox_win.h for details).
|
||||||
///
|
///
|
||||||
CEF_EXPORT int cef_initialize(const struct _cef_main_args_t* args,
|
CEF_EXPORT int cef_initialize(const cef_main_args_t* args,
|
||||||
const struct _cef_settings_t* settings,
|
const struct _cef_settings_t* settings,
|
||||||
cef_app_t* application,
|
cef_app_t* application,
|
||||||
void* windows_sandbox_info);
|
void* windows_sandbox_info);
|
||||||
|
|
||||||
///
|
///
|
||||||
// This function should be called on the main application thread to shut down
|
/// This function can optionally be called on the main application thread after
|
||||||
// the CEF browser process before the application exits.
|
/// CefInitialize to retrieve the initialization exit code. When CefInitialize
|
||||||
|
/// returns true (1) the exit code will be 0 (CEF_RESULT_CODE_NORMAL_EXIT).
|
||||||
|
/// Otherwise, see cef_resultcode_t for possible exit code values including
|
||||||
|
/// browser process initialization errors and normal early exit conditions (such
|
||||||
|
/// as CEF_RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED for process singleton
|
||||||
|
/// relaunch behavior).
|
||||||
///
|
///
|
||||||
CEF_EXPORT void cef_shutdown();
|
CEF_EXPORT int cef_get_exit_code(void);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Perform a single iteration of CEF message loop processing. This function is
|
/// This function should be called on the main application thread to shut down
|
||||||
// provided for cases where the CEF message loop must be integrated into an
|
/// the CEF browser process before the application exits. Do not call any other
|
||||||
// existing application message loop. Use of this function is not recommended
|
/// CEF functions after calling this function.
|
||||||
// for most users; use either the cef_run_message_loop() function or
|
|
||||||
// CefSettings.multi_threaded_message_loop if possible. When using this function
|
|
||||||
// care must be taken to balance performance against excessive CPU usage. It is
|
|
||||||
// recommended to enable the CefSettings.external_message_pump option when using
|
|
||||||
// this function so that
|
|
||||||
// cef_browser_process_handler_t::on_schedule_message_pump_work() callbacks can
|
|
||||||
// facilitate the scheduling process. This function should only be called on the
|
|
||||||
// main application thread and only if cef_initialize() is called with a
|
|
||||||
// CefSettings.multi_threaded_message_loop value of false (0). This function
|
|
||||||
// will not block.
|
|
||||||
///
|
///
|
||||||
CEF_EXPORT void cef_do_message_loop_work();
|
CEF_EXPORT void cef_shutdown(void);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Run the CEF message loop. Use this function instead of an application-
|
/// Perform a single iteration of CEF message loop processing. This function is
|
||||||
// provided message loop to get the best balance between performance and CPU
|
/// provided for cases where the CEF message loop must be integrated into an
|
||||||
// usage. This function should only be called on the main application thread and
|
/// existing application message loop. Use of this function is not recommended
|
||||||
// only if cef_initialize() is called with a
|
/// for most users; use either the cef_run_message_loop() function or
|
||||||
// CefSettings.multi_threaded_message_loop value of false (0). This function
|
/// cef_settings_t.multi_threaded_message_loop if possible. When using this
|
||||||
// will block until a quit message is received by the system.
|
/// function care must be taken to balance performance against excessive CPU
|
||||||
|
/// usage. It is recommended to enable the cef_settings_t.external_message_pump
|
||||||
|
/// option when using this function so that
|
||||||
|
/// cef_browser_process_handler_t::on_schedule_message_pump_work() callbacks can
|
||||||
|
/// facilitate the scheduling process. This function should only be called on
|
||||||
|
/// the main application thread and only if cef_initialize() is called with a
|
||||||
|
/// cef_settings_t.multi_threaded_message_loop value of false (0). This function
|
||||||
|
/// will not block.
|
||||||
///
|
///
|
||||||
CEF_EXPORT void cef_run_message_loop();
|
CEF_EXPORT void cef_do_message_loop_work(void);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Quit the CEF message loop that was started by calling cef_run_message_loop().
|
/// Run the CEF message loop. Use this function instead of an application-
|
||||||
// This function should only be called on the main application thread and only
|
/// provided message loop to get the best balance between performance and CPU
|
||||||
// if cef_run_message_loop() was used.
|
/// usage. This function should only be called on the main application thread
|
||||||
|
/// and only if cef_initialize() is called with a
|
||||||
|
/// cef_settings_t.multi_threaded_message_loop value of false (0). This function
|
||||||
|
/// will block until a quit message is received by the system.
|
||||||
///
|
///
|
||||||
CEF_EXPORT void cef_quit_message_loop();
|
CEF_EXPORT void cef_run_message_loop(void);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set to true (1) before calling Windows APIs like TrackPopupMenu that enter a
|
/// Quit the CEF message loop that was started by calling
|
||||||
// modal message loop. Set to false (0) after exiting the modal message loop.
|
/// cef_run_message_loop(). This function should only be called on the main
|
||||||
|
/// application thread and only if cef_run_message_loop() was used.
|
||||||
///
|
///
|
||||||
CEF_EXPORT void cef_set_osmodal_loop(int osModalLoop);
|
CEF_EXPORT void cef_quit_message_loop(void);
|
||||||
|
|
||||||
///
|
|
||||||
// Call during process startup to enable High-DPI support on Windows 7 or newer.
|
|
||||||
// Older versions of Windows should be left DPI-unaware because they do not
|
|
||||||
// support DirectWrite and GDI fonts are kerned very badly.
|
|
||||||
///
|
|
||||||
CEF_EXPORT void cef_enable_highdpi_support();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=0385a38b6761c5dec07bb89a95a007ad3c11bea6$
|
// $hash=def41651170c930805bd36e9640c98cb87c79529$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_AUDIO_HANDLER_CAPI_H_
|
||||||
@@ -48,59 +48,70 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle audio events All functions will be called
|
/// Implement this structure to handle audio events.
|
||||||
// on the UI thread
|
|
||||||
///
|
///
|
||||||
typedef struct _cef_audio_handler_t {
|
typedef struct _cef_audio_handler_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the stream identified by |audio_stream_id| has started.
|
/// Called on the UI thread to allow configuration of audio stream parameters.
|
||||||
// |audio_stream_id| will uniquely identify the stream across all future
|
/// Return true (1) to proceed with audio stream capture, or false (0) to
|
||||||
// cef_audio_handler_t callbacks. OnAudioSteamStopped will always be called
|
/// cancel it. All members of |params| can optionally be configured here, but
|
||||||
// after OnAudioStreamStarted; both functions may be called multiple times for
|
/// they are also pre-filled with some sensible defaults.
|
||||||
// the same stream. |channels| is the number of channels, |channel_layout| is
|
///
|
||||||
// the layout of the channels and |sample_rate| is the stream sample rate.
|
int(CEF_CALLBACK* get_audio_parameters)(struct _cef_audio_handler_t* self,
|
||||||
// |frames_per_buffer| is the maximum number of frames that will occur in the
|
struct _cef_browser_t* browser,
|
||||||
// PCM packet passed to OnAudioStreamPacket.
|
cef_audio_parameters_t* params);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called on a browser audio capture thread when the browser starts streaming
|
||||||
|
/// audio. OnAudioStreamStopped will always be called after
|
||||||
|
/// OnAudioStreamStarted; both functions may be called multiple times for the
|
||||||
|
/// same browser. |params| contains the audio parameters like sample rate and
|
||||||
|
/// channel layout. |channels| is the number of channels.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_audio_stream_started)(
|
void(CEF_CALLBACK* on_audio_stream_started)(
|
||||||
struct _cef_audio_handler_t* self,
|
struct _cef_audio_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
int audio_stream_id,
|
const cef_audio_parameters_t* params,
|
||||||
int channels,
|
int channels);
|
||||||
cef_channel_layout_t channel_layout,
|
|
||||||
int sample_rate,
|
|
||||||
int frames_per_buffer);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when a PCM packet is received for the stream identified by
|
/// Called on the audio stream thread when a PCM packet is received for the
|
||||||
// |audio_stream_id|. |data| is an array representing the raw PCM data as a
|
/// stream. |data| is an array representing the raw PCM data as a floating
|
||||||
// floating point type, i.e. 4-byte value(s). |frames| is the number of frames
|
/// point type, i.e. 4-byte value(s). |frames| is the number of frames in the
|
||||||
// in the PCM packet. |pts| is the presentation timestamp (in milliseconds
|
/// PCM packet. |pts| is the presentation timestamp (in milliseconds since the
|
||||||
// since the Unix Epoch) and represents the time at which the decompressed
|
/// Unix Epoch) and represents the time at which the decompressed packet
|
||||||
// packet should be presented to the user. Based on |frames| and the
|
/// should be presented to the user. Based on |frames| and the
|
||||||
// |channel_layout| value passed to OnAudioStreamStarted you can calculate the
|
/// |channel_layout| value passed to OnAudioStreamStarted you can calculate
|
||||||
// size of the |data| array in bytes.
|
/// the size of the |data| array in bytes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_audio_stream_packet)(struct _cef_audio_handler_t* self,
|
void(CEF_CALLBACK* on_audio_stream_packet)(struct _cef_audio_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
int audio_stream_id,
|
|
||||||
const float** data,
|
const float** data,
|
||||||
int frames,
|
int frames,
|
||||||
int64 pts);
|
int64_t pts);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the stream identified by |audio_stream_id| has stopped.
|
/// Called on the UI thread when the stream has stopped. OnAudioSteamStopped
|
||||||
// OnAudioSteamStopped will always be called after OnAudioStreamStarted; both
|
/// will always be called after OnAudioStreamStarted; both functions may be
|
||||||
// functions may be called multiple times for the same stream.
|
/// called multiple times for the same stream.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_audio_stream_stopped)(struct _cef_audio_handler_t* self,
|
void(CEF_CALLBACK* on_audio_stream_stopped)(struct _cef_audio_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser);
|
||||||
int audio_stream_id);
|
|
||||||
|
///
|
||||||
|
/// Called on the UI or audio stream thread when an error occurred. During the
|
||||||
|
/// stream creation phase this callback will be called on the UI thread while
|
||||||
|
/// in the capturing phase it will be called on the audio stream thread. The
|
||||||
|
/// stream will be stopped immediately.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* on_audio_stream_error)(struct _cef_audio_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
const cef_string_t* message);
|
||||||
} cef_audio_handler_t;
|
} cef_audio_handler_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=9f05ee0596b82355ba8c07dcd8244a761b95df58$
|
// $hash=c20b65725d97c5a9e09ae76c082c361935941a37$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_AUTH_CALLBACK_CAPI_H_
|
||||||
@@ -47,24 +47,24 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Callback structure used for asynchronous continuation of authentication
|
/// Callback structure used for asynchronous continuation of authentication
|
||||||
// requests.
|
/// requests.
|
||||||
///
|
///
|
||||||
typedef struct _cef_auth_callback_t {
|
typedef struct _cef_auth_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Continue the authentication request.
|
/// Continue the authentication request.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_auth_callback_t* self,
|
void(CEF_CALLBACK* cont)(struct _cef_auth_callback_t* self,
|
||||||
const cef_string_t* username,
|
const cef_string_t* username,
|
||||||
const cef_string_t* password);
|
const cef_string_t* password);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Cancel the authentication request.
|
/// Cancel the authentication request.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cancel)(struct _cef_auth_callback_t* self);
|
void(CEF_CALLBACK* cancel)(struct _cef_auth_callback_t* self);
|
||||||
} cef_auth_callback_t;
|
} cef_auth_callback_t;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=372bc8b015110d2849eb1d8c16b616871e2d9320$
|
// $hash=2130ee468c9742d5be99d622703829adff83145f$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||||
@@ -41,8 +41,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "include/capi/cef_base_capi.h"
|
#include "include/capi/cef_base_capi.h"
|
||||||
|
#include "include/capi/cef_client_capi.h"
|
||||||
#include "include/capi/cef_command_line_capi.h"
|
#include "include/capi/cef_command_line_capi.h"
|
||||||
#include "include/capi/cef_print_handler_capi.h"
|
#include "include/capi/cef_preference_capi.h"
|
||||||
|
#include "include/capi/cef_request_context_handler_capi.h"
|
||||||
#include "include/capi/cef_values_capi.h"
|
#include "include/capi/cef_values_capi.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -50,68 +52,121 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used to implement browser process callbacks. The functions of this
|
/// Structure used to implement browser process callbacks. The functions of this
|
||||||
// structure will be called on the browser process main thread unless otherwise
|
/// structure will be called on the browser process main thread unless otherwise
|
||||||
// indicated.
|
/// indicated.
|
||||||
///
|
///
|
||||||
typedef struct _cef_browser_process_handler_t {
|
typedef struct _cef_browser_process_handler_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the browser process UI thread immediately after the CEF context
|
/// Provides an opportunity to register custom preferences prior to global and
|
||||||
// has been initialized.
|
/// request context initialization.
|
||||||
|
///
|
||||||
|
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
||||||
|
/// accessed via cef_preference_manager_t::GetGlobalPreferences after
|
||||||
|
/// OnContextInitialized is called. Global preferences are registered a single
|
||||||
|
/// time at application startup. See related cef_settings_t.cache_path
|
||||||
|
/// configuration.
|
||||||
|
///
|
||||||
|
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
||||||
|
/// accessed via the cef_request_context_t after
|
||||||
|
/// cef_request_context_handler_t::OnRequestContextInitialized is called.
|
||||||
|
/// Request context preferences are registered each time a new
|
||||||
|
/// cef_request_context_t is created. It is intended but not required that all
|
||||||
|
/// request contexts have the same registered preferences. See related
|
||||||
|
/// cef_request_context_settings_t.cache_path configuration.
|
||||||
|
///
|
||||||
|
/// Do not keep a reference to the |registrar| object. This function is called
|
||||||
|
/// on the browser process UI thread.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* on_register_custom_preferences)(
|
||||||
|
struct _cef_browser_process_handler_t* self,
|
||||||
|
cef_preferences_type_t type,
|
||||||
|
struct _cef_preference_registrar_t* registrar);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called on the browser process UI thread immediately after the CEF context
|
||||||
|
/// has been initialized.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_context_initialized)(
|
void(CEF_CALLBACK* on_context_initialized)(
|
||||||
struct _cef_browser_process_handler_t* self);
|
struct _cef_browser_process_handler_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called before a child process is launched. Will be called on the browser
|
/// Called before a child process is launched. Will be called on the browser
|
||||||
// process UI thread when launching a render process and on the browser
|
/// process UI thread when launching a render process and on the browser
|
||||||
// process IO thread when launching a GPU or plugin process. Provides an
|
/// process IO thread when launching a GPU process. Provides an opportunity to
|
||||||
// opportunity to modify the child process command line. Do not keep a
|
/// modify the child process command line. Do not keep a reference to
|
||||||
// reference to |command_line| outside of this function.
|
/// |command_line| outside of this function.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_before_child_process_launch)(
|
void(CEF_CALLBACK* on_before_child_process_launch)(
|
||||||
struct _cef_browser_process_handler_t* self,
|
struct _cef_browser_process_handler_t* self,
|
||||||
struct _cef_command_line_t* command_line);
|
struct _cef_command_line_t* command_line);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the browser process IO thread after the main thread has been
|
/// Implement this function to provide app-specific behavior when an already
|
||||||
// created for a new render process. Provides an opportunity to specify extra
|
/// running app is relaunched with the same CefSettings.root_cache_path value.
|
||||||
// information that will be passed to
|
/// For example, activate an existing app window or create a new app window.
|
||||||
// cef_render_process_handler_t::on_render_thread_created() in the render
|
/// |command_line| will be read-only. Do not keep a reference to
|
||||||
// process. Do not keep a reference to |extra_info| outside of this function.
|
/// |command_line| outside of this function. Return true (1) if the relaunch
|
||||||
|
/// is handled or false (0) for default relaunch behavior. Default behavior
|
||||||
|
/// will create a new default styled Chrome window.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_render_process_thread_created)(
|
/// To avoid cache corruption only a single app instance is allowed to run for
|
||||||
|
/// a given CefSettings.root_cache_path value. On relaunch the app checks a
|
||||||
|
/// process singleton lock and then forwards the new launch arguments to the
|
||||||
|
/// already running app process before exiting early. Client apps should
|
||||||
|
/// therefore check the cef_initialize() return value for early exit before
|
||||||
|
/// proceeding.
|
||||||
|
///
|
||||||
|
/// This function will be called on the browser process UI thread.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* on_already_running_app_relaunch)(
|
||||||
struct _cef_browser_process_handler_t* self,
|
struct _cef_browser_process_handler_t* self,
|
||||||
struct _cef_list_value_t* extra_info);
|
struct _cef_command_line_t* command_line,
|
||||||
|
const cef_string_t* current_directory);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for printing on Linux. If a print handler is not
|
/// Called from any thread when work has been scheduled for the browser
|
||||||
// provided then printing will not be supported on the Linux platform.
|
/// process main (UI) thread. This callback is used in combination with
|
||||||
///
|
/// cef_settings_t.external_message_pump and cef_do_message_loop_work() in
|
||||||
struct _cef_print_handler_t*(CEF_CALLBACK* get_print_handler)(
|
/// cases where the CEF message loop must be integrated into an existing
|
||||||
struct _cef_browser_process_handler_t* self);
|
/// application message loop (see additional comments and warnings on
|
||||||
|
/// CefDoMessageLoopWork). This callback should schedule a
|
||||||
///
|
/// cef_do_message_loop_work() call to happen on the main (UI) thread.
|
||||||
// Called from any thread when work has been scheduled for the browser process
|
/// |delay_ms| is the requested delay in milliseconds. If |delay_ms| is <= 0
|
||||||
// main (UI) thread. This callback is used in combination with CefSettings.
|
/// then the call should happen reasonably soon. If |delay_ms| is > 0 then the
|
||||||
// external_message_pump and cef_do_message_loop_work() in cases where the CEF
|
/// call should be scheduled to happen after the specified delay and any
|
||||||
// message loop must be integrated into an existing application message loop
|
/// currently pending scheduled call should be cancelled.
|
||||||
// (see additional comments and warnings on CefDoMessageLoopWork). This
|
|
||||||
// callback should schedule a cef_do_message_loop_work() call to happen on the
|
|
||||||
// main (UI) thread. |delay_ms| is the requested delay in milliseconds. If
|
|
||||||
// |delay_ms| is <= 0 then the call should happen reasonably soon. If
|
|
||||||
// |delay_ms| is > 0 then the call should be scheduled to happen after the
|
|
||||||
// specified delay and any currently pending scheduled call should be
|
|
||||||
// cancelled.
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_schedule_message_pump_work)(
|
void(CEF_CALLBACK* on_schedule_message_pump_work)(
|
||||||
struct _cef_browser_process_handler_t* self,
|
struct _cef_browser_process_handler_t* self,
|
||||||
int64 delay_ms);
|
int64_t delay_ms);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return the default client for use with a newly created browser window
|
||||||
|
/// (cef_browser_t object). If null is returned the cef_browser_t will be
|
||||||
|
/// unmanaged (no callbacks will be executed for that cef_browser_t) and
|
||||||
|
/// application shutdown will be blocked until the browser window is closed
|
||||||
|
/// manually. This function is currently only used with Chrome style when
|
||||||
|
/// creating new browser windows via Chrome UI.
|
||||||
|
///
|
||||||
|
struct _cef_client_t*(CEF_CALLBACK* get_default_client)(
|
||||||
|
struct _cef_browser_process_handler_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return the default handler for use with a new user or incognito profile
|
||||||
|
/// (cef_request_context_t object). If null is returned the
|
||||||
|
/// cef_request_context_t will be unmanaged (no callbacks will be executed for
|
||||||
|
/// that cef_request_context_t). This function is currently only used with
|
||||||
|
/// Chrome style when creating new browser windows via Chrome UI.
|
||||||
|
///
|
||||||
|
struct _cef_request_context_handler_t*(
|
||||||
|
CEF_CALLBACK* get_default_request_context_handler)(
|
||||||
|
struct _cef_browser_process_handler_t* self);
|
||||||
} cef_browser_process_handler_t;
|
} cef_browser_process_handler_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=7419140aa82db2a86a5eca062193ac8bde9f5d40$
|
// $hash=7aed80e6f53e47cadf5ab5ef5eace1a208378bd6$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_CALLBACK_CAPI_H_
|
||||||
@@ -47,36 +47,36 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Generic callback structure used for asynchronous continuation.
|
/// Generic callback structure used for asynchronous continuation.
|
||||||
///
|
///
|
||||||
typedef struct _cef_callback_t {
|
typedef struct _cef_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Continue processing.
|
/// Continue processing.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_callback_t* self);
|
void(CEF_CALLBACK* cont)(struct _cef_callback_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Cancel processing.
|
/// Cancel processing.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cancel)(struct _cef_callback_t* self);
|
void(CEF_CALLBACK* cancel)(struct _cef_callback_t* self);
|
||||||
} cef_callback_t;
|
} cef_callback_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Generic callback structure used for asynchronous completion.
|
/// Generic callback structure used for asynchronous completion.
|
||||||
///
|
///
|
||||||
typedef struct _cef_completion_callback_t {
|
typedef struct _cef_completion_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Method that will be called once the task is complete.
|
/// Method that will be called once the task is complete.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_complete)(struct _cef_completion_callback_t* self);
|
void(CEF_CALLBACK* on_complete)(struct _cef_completion_callback_t* self);
|
||||||
} cef_completion_callback_t;
|
} cef_completion_callback_t;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=485de431252b72e5516f3f7f16a8d6f416801dfd$
|
// $hash=6ae90159e832b94846a72b59cf1d40a55676cd55$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include "include/capi/cef_audio_handler_capi.h"
|
#include "include/capi/cef_audio_handler_capi.h"
|
||||||
#include "include/capi/cef_base_capi.h"
|
#include "include/capi/cef_base_capi.h"
|
||||||
|
#include "include/capi/cef_command_handler_capi.h"
|
||||||
#include "include/capi/cef_context_menu_handler_capi.h"
|
#include "include/capi/cef_context_menu_handler_capi.h"
|
||||||
#include "include/capi/cef_dialog_handler_capi.h"
|
#include "include/capi/cef_dialog_handler_capi.h"
|
||||||
#include "include/capi/cef_display_handler_capi.h"
|
#include "include/capi/cef_display_handler_capi.h"
|
||||||
@@ -49,10 +50,13 @@
|
|||||||
#include "include/capi/cef_drag_handler_capi.h"
|
#include "include/capi/cef_drag_handler_capi.h"
|
||||||
#include "include/capi/cef_find_handler_capi.h"
|
#include "include/capi/cef_find_handler_capi.h"
|
||||||
#include "include/capi/cef_focus_handler_capi.h"
|
#include "include/capi/cef_focus_handler_capi.h"
|
||||||
|
#include "include/capi/cef_frame_handler_capi.h"
|
||||||
#include "include/capi/cef_jsdialog_handler_capi.h"
|
#include "include/capi/cef_jsdialog_handler_capi.h"
|
||||||
#include "include/capi/cef_keyboard_handler_capi.h"
|
#include "include/capi/cef_keyboard_handler_capi.h"
|
||||||
#include "include/capi/cef_life_span_handler_capi.h"
|
#include "include/capi/cef_life_span_handler_capi.h"
|
||||||
#include "include/capi/cef_load_handler_capi.h"
|
#include "include/capi/cef_load_handler_capi.h"
|
||||||
|
#include "include/capi/cef_permission_handler_capi.h"
|
||||||
|
#include "include/capi/cef_print_handler_capi.h"
|
||||||
#include "include/capi/cef_process_message_capi.h"
|
#include "include/capi/cef_process_message_capi.h"
|
||||||
#include "include/capi/cef_render_handler_capi.h"
|
#include "include/capi/cef_render_handler_capi.h"
|
||||||
#include "include/capi/cef_request_handler_capi.h"
|
#include "include/capi/cef_request_handler_capi.h"
|
||||||
@@ -62,110 +66,139 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to provide handler implementations.
|
/// Implement this structure to provide handler implementations.
|
||||||
///
|
///
|
||||||
typedef struct _cef_client_t {
|
typedef struct _cef_client_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for audio rendering events.
|
/// Return the handler for audio rendering events.
|
||||||
///
|
///
|
||||||
struct _cef_audio_handler_t*(CEF_CALLBACK* get_audio_handler)(
|
struct _cef_audio_handler_t*(CEF_CALLBACK* get_audio_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for context menus. If no handler is provided the default
|
/// Return the handler for commands. If no handler is provided the default
|
||||||
// implementation will be used.
|
/// implementation will be used.
|
||||||
|
///
|
||||||
|
struct _cef_command_handler_t*(CEF_CALLBACK* get_command_handler)(
|
||||||
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return the handler for context menus. If no handler is provided the
|
||||||
|
/// default implementation will be used.
|
||||||
///
|
///
|
||||||
struct _cef_context_menu_handler_t*(CEF_CALLBACK* get_context_menu_handler)(
|
struct _cef_context_menu_handler_t*(CEF_CALLBACK* get_context_menu_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for dialogs. If no handler is provided the default
|
/// Return the handler for dialogs. If no handler is provided the default
|
||||||
// implementation will be used.
|
/// implementation will be used.
|
||||||
///
|
///
|
||||||
struct _cef_dialog_handler_t*(CEF_CALLBACK* get_dialog_handler)(
|
struct _cef_dialog_handler_t*(CEF_CALLBACK* get_dialog_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser display state events.
|
/// Return the handler for browser display state events.
|
||||||
///
|
///
|
||||||
struct _cef_display_handler_t*(CEF_CALLBACK* get_display_handler)(
|
struct _cef_display_handler_t*(CEF_CALLBACK* get_display_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for download events. If no handler is returned downloads
|
/// Return the handler for download events. If no handler is returned
|
||||||
// will not be allowed.
|
/// downloads will not be allowed.
|
||||||
///
|
///
|
||||||
struct _cef_download_handler_t*(CEF_CALLBACK* get_download_handler)(
|
struct _cef_download_handler_t*(CEF_CALLBACK* get_download_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for drag events.
|
/// Return the handler for drag events.
|
||||||
///
|
///
|
||||||
struct _cef_drag_handler_t*(CEF_CALLBACK* get_drag_handler)(
|
struct _cef_drag_handler_t*(CEF_CALLBACK* get_drag_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for find result events.
|
/// Return the handler for find result events.
|
||||||
///
|
///
|
||||||
struct _cef_find_handler_t*(CEF_CALLBACK* get_find_handler)(
|
struct _cef_find_handler_t*(CEF_CALLBACK* get_find_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for focus events.
|
/// Return the handler for focus events.
|
||||||
///
|
///
|
||||||
struct _cef_focus_handler_t*(CEF_CALLBACK* get_focus_handler)(
|
struct _cef_focus_handler_t*(CEF_CALLBACK* get_focus_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for JavaScript dialogs. If no handler is provided the
|
/// Return the handler for events related to cef_frame_t lifespan. This
|
||||||
// default implementation will be used.
|
/// function will be called once during cef_browser_t creation and the result
|
||||||
|
/// will be cached for performance reasons.
|
||||||
|
///
|
||||||
|
struct _cef_frame_handler_t*(CEF_CALLBACK* get_frame_handler)(
|
||||||
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return the handler for permission requests.
|
||||||
|
///
|
||||||
|
struct _cef_permission_handler_t*(CEF_CALLBACK* get_permission_handler)(
|
||||||
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return the handler for JavaScript dialogs. If no handler is provided the
|
||||||
|
/// default implementation will be used.
|
||||||
///
|
///
|
||||||
struct _cef_jsdialog_handler_t*(CEF_CALLBACK* get_jsdialog_handler)(
|
struct _cef_jsdialog_handler_t*(CEF_CALLBACK* get_jsdialog_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for keyboard events.
|
/// Return the handler for keyboard events.
|
||||||
///
|
///
|
||||||
struct _cef_keyboard_handler_t*(CEF_CALLBACK* get_keyboard_handler)(
|
struct _cef_keyboard_handler_t*(CEF_CALLBACK* get_keyboard_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser life span events.
|
/// Return the handler for browser life span events.
|
||||||
///
|
///
|
||||||
struct _cef_life_span_handler_t*(CEF_CALLBACK* get_life_span_handler)(
|
struct _cef_life_span_handler_t*(CEF_CALLBACK* get_life_span_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser load status events.
|
/// Return the handler for browser load status events.
|
||||||
///
|
///
|
||||||
struct _cef_load_handler_t*(CEF_CALLBACK* get_load_handler)(
|
struct _cef_load_handler_t*(CEF_CALLBACK* get_load_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for off-screen rendering events.
|
/// Return the handler for printing on Linux. If a print handler is not
|
||||||
|
/// provided then printing will not be supported on the Linux platform.
|
||||||
|
///
|
||||||
|
struct _cef_print_handler_t*(CEF_CALLBACK* get_print_handler)(
|
||||||
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Return the handler for off-screen rendering events.
|
||||||
///
|
///
|
||||||
struct _cef_render_handler_t*(CEF_CALLBACK* get_render_handler)(
|
struct _cef_render_handler_t*(CEF_CALLBACK* get_render_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Return the handler for browser request events.
|
/// Return the handler for browser request events.
|
||||||
///
|
///
|
||||||
struct _cef_request_handler_t*(CEF_CALLBACK* get_request_handler)(
|
struct _cef_request_handler_t*(CEF_CALLBACK* get_request_handler)(
|
||||||
struct _cef_client_t* self);
|
struct _cef_client_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when a new message is received from a different process. Return true
|
/// Called when a new message is received from a different process. Return
|
||||||
// (1) if the message was handled or false (0) otherwise. Do not keep a
|
/// true (1) if the message was handled or false (0) otherwise. It is safe to
|
||||||
// reference to or attempt to access the message outside of this callback.
|
/// keep a reference to |message| outside of this callback.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_process_message_received)(
|
int(CEF_CALLBACK* on_process_message_received)(
|
||||||
struct _cef_client_t* self,
|
struct _cef_client_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
|
struct _cef_frame_t* frame,
|
||||||
cef_process_id_t source_process,
|
cef_process_id_t source_process,
|
||||||
struct _cef_process_message_t* message);
|
struct _cef_process_message_t* message);
|
||||||
} cef_client_t;
|
} cef_client_t;
|
||||||
|
|||||||
118
include/capi/cef_command_handler_capi.h
Normal file
118
include/capi/cef_command_handler_capi.h
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool and should not edited
|
||||||
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
|
// more information.
|
||||||
|
//
|
||||||
|
// $hash=43f3df7da1d27b568b19c2cf0b1d3a62282e132b$
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_HANDLER_CAPI_H_
|
||||||
|
#define CEF_INCLUDE_CAPI_CEF_COMMAND_HANDLER_CAPI_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/capi/cef_base_capi.h"
|
||||||
|
#include "include/capi/cef_browser_capi.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Implement this structure to handle events related to commands. The functions
|
||||||
|
/// of this structure will be called on the UI thread.
|
||||||
|
///
|
||||||
|
typedef struct _cef_command_handler_t {
|
||||||
|
///
|
||||||
|
/// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called to execute a Chrome command triggered via menu selection or
|
||||||
|
/// keyboard shortcut. Values for |command_id| can be found in the
|
||||||
|
/// cef_command_ids.h file. |disposition| provides information about the
|
||||||
|
/// intended command target. Return true (1) if the command was handled or
|
||||||
|
/// false (0) for the default implementation. For context menu commands this
|
||||||
|
/// will be called after cef_context_menu_handler_t::OnContextMenuCommand.
|
||||||
|
/// Only used with Chrome style.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* on_chrome_command)(
|
||||||
|
struct _cef_command_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
int command_id,
|
||||||
|
cef_window_open_disposition_t disposition);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called to check if a Chrome app menu item should be visible. Values for
|
||||||
|
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
||||||
|
/// menu items that would be visible by default. Only used with Chrome style.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* is_chrome_app_menu_item_visible)(
|
||||||
|
struct _cef_command_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
int command_id);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called to check if a Chrome app menu item should be enabled. Values for
|
||||||
|
/// |command_id| can be found in the cef_command_ids.h file. Only called for
|
||||||
|
/// menu items that would be enabled by default. Only used with Chrome style.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* is_chrome_app_menu_item_enabled)(
|
||||||
|
struct _cef_command_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
int command_id);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called during browser creation to check if a Chrome page action icon
|
||||||
|
/// should be visible. Only called for icons that would be visible by default.
|
||||||
|
/// Only used with Chrome style.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* is_chrome_page_action_icon_visible)(
|
||||||
|
struct _cef_command_handler_t* self,
|
||||||
|
cef_chrome_page_action_icon_type_t icon_type);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called during browser creation to check if a Chrome toolbar button should
|
||||||
|
/// be visible. Only called for buttons that would be visible by default. Only
|
||||||
|
/// used with Chrome style.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* is_chrome_toolbar_button_visible)(
|
||||||
|
struct _cef_command_handler_t* self,
|
||||||
|
cef_chrome_toolbar_button_type_t button_type);
|
||||||
|
} cef_command_handler_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CAPI_CEF_COMMAND_HANDLER_CAPI_H_
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=540c73b297f3b0843058881c5a9a7433dc346fd2$
|
// $hash=eec6c6c5bb382d519e8784dc9a5738351bd7e134$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_COMMAND_LINE_CAPI_H_
|
||||||
@@ -47,103 +47,104 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used to create and/or parse command line arguments. Arguments with
|
/// Structure used to create and/or parse command line arguments. Arguments with
|
||||||
// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches
|
/// "--", "-" and, on Windows, "/" prefixes are considered switches. Switches
|
||||||
// will always precede any arguments without switch prefixes. Switches can
|
/// will always precede any arguments without switch prefixes. Switches can
|
||||||
// optionally have a value specified using the '=' delimiter (e.g.
|
/// optionally have a value specified using the "=" delimiter (e.g.
|
||||||
// "-switch=value"). An argument of "--" will terminate switch parsing with all
|
/// "-switch=value"). An argument of "--" will terminate switch parsing with all
|
||||||
// subsequent tokens, regardless of prefix, being interpreted as non-switch
|
/// subsequent tokens, regardless of prefix, being interpreted as non-switch
|
||||||
// arguments. Switch names are considered case-insensitive. This structure can
|
/// arguments. Switch names should be lowercase ASCII and will be converted to
|
||||||
// be used before cef_initialize() is called.
|
/// such if necessary. Switch values will retain the original case and UTF8
|
||||||
|
/// encoding. This structure can be used before cef_initialize() is called.
|
||||||
///
|
///
|
||||||
typedef struct _cef_command_line_t {
|
typedef struct _cef_command_line_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if this object is valid. Do not call any other functions
|
/// Returns true (1) if this object is valid. Do not call any other functions
|
||||||
// if this function returns false (0).
|
/// if this function returns false (0).
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_valid)(struct _cef_command_line_t* self);
|
int(CEF_CALLBACK* is_valid)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the values of this object are read-only. Some APIs may
|
/// Returns true (1) if the values of this object are read-only. Some APIs may
|
||||||
// expose read-only objects.
|
/// expose read-only objects.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_read_only)(struct _cef_command_line_t* self);
|
int(CEF_CALLBACK* is_read_only)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns a writable copy of this object.
|
/// Returns a writable copy of this object.
|
||||||
///
|
///
|
||||||
struct _cef_command_line_t*(CEF_CALLBACK* copy)(
|
struct _cef_command_line_t*(CEF_CALLBACK* copy)(
|
||||||
struct _cef_command_line_t* self);
|
struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Initialize the command line with the specified |argc| and |argv| values.
|
/// Initialize the command line with the specified |argc| and |argv| values.
|
||||||
// The first argument must be the name of the program. This function is only
|
/// The first argument must be the name of the program. This function is only
|
||||||
// supported on non-Windows platforms.
|
/// supported on non-Windows platforms.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* init_from_argv)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* init_from_argv)(struct _cef_command_line_t* self,
|
||||||
int argc,
|
int argc,
|
||||||
const char* const* argv);
|
const char* const* argv);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Initialize the command line with the string returned by calling
|
/// Initialize the command line with the string returned by calling
|
||||||
// GetCommandLineW(). This function is only supported on Windows.
|
/// GetCommandLineW(). This function is only supported on Windows.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* init_from_string)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* init_from_string)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* command_line);
|
const cef_string_t* command_line);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Reset the command-line switches and arguments but leave the program
|
/// Reset the command-line switches and arguments but leave the program
|
||||||
// component unchanged.
|
/// component unchanged.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* reset)(struct _cef_command_line_t* self);
|
void(CEF_CALLBACK* reset)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Retrieve the original command line string as a vector of strings. The argv
|
/// Retrieve the original command line string as a vector of strings. The argv
|
||||||
// array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
|
/// array: `{ program, [(--|-|/)switch[=value]]*, [--], [argument]* }`
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* get_argv)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* get_argv)(struct _cef_command_line_t* self,
|
||||||
cef_string_list_t argv);
|
cef_string_list_t argv);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Constructs and returns the represented command line string. Use this
|
/// Constructs and returns the represented command line string. Use this
|
||||||
// function cautiously because quoting behavior is unclear.
|
/// function cautiously because quoting behavior is unclear.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_command_line_string)(
|
cef_string_userfree_t(CEF_CALLBACK* get_command_line_string)(
|
||||||
struct _cef_command_line_t* self);
|
struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Get the program part of the command line string (the first item).
|
/// Get the program part of the command line string (the first item).
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_program)(
|
cef_string_userfree_t(CEF_CALLBACK* get_program)(
|
||||||
struct _cef_command_line_t* self);
|
struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the program part of the command line string (the first item).
|
/// Set the program part of the command line string (the first item).
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* set_program)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* set_program)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* program);
|
const cef_string_t* program);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the command line has switches.
|
/// Returns true (1) if the command line has switches.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_switches)(struct _cef_command_line_t* self);
|
int(CEF_CALLBACK* has_switches)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the command line contains the given switch.
|
/// Returns true (1) if the command line contains the given switch.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_switch)(struct _cef_command_line_t* self,
|
int(CEF_CALLBACK* has_switch)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* name);
|
const cef_string_t* name);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the value associated with the given switch. If the switch has no
|
/// Returns the value associated with the given switch. If the switch has no
|
||||||
// value or isn't present this function returns the NULL string.
|
/// value or isn't present this function returns the NULL string.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_switch_value)(
|
cef_string_userfree_t(CEF_CALLBACK* get_switch_value)(
|
||||||
@@ -151,61 +152,61 @@ typedef struct _cef_command_line_t {
|
|||||||
const cef_string_t* name);
|
const cef_string_t* name);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the map of switch names and values. If a switch has no value an
|
/// Returns the map of switch names and values. If a switch has no value an
|
||||||
// NULL string is returned.
|
/// NULL string is returned.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* get_switches)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* get_switches)(struct _cef_command_line_t* self,
|
||||||
cef_string_map_t switches);
|
cef_string_map_t switches);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add a switch to the end of the command line. If the switch has no value
|
/// Add a switch to the end of the command line.
|
||||||
// pass an NULL value string.
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* append_switch)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* append_switch)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* name);
|
const cef_string_t* name);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add a switch with the specified value to the end of the command line.
|
/// Add a switch with the specified value to the end of the command line. If
|
||||||
|
/// the switch has no value pass an NULL value string.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* append_switch_with_value)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* append_switch_with_value)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* name,
|
const cef_string_t* name,
|
||||||
const cef_string_t* value);
|
const cef_string_t* value);
|
||||||
|
|
||||||
///
|
///
|
||||||
// True if there are remaining command line arguments.
|
/// True if there are remaining command line arguments.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_arguments)(struct _cef_command_line_t* self);
|
int(CEF_CALLBACK* has_arguments)(struct _cef_command_line_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Get the remaining command line arguments.
|
/// Get the remaining command line arguments.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* get_arguments)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* get_arguments)(struct _cef_command_line_t* self,
|
||||||
cef_string_list_t arguments);
|
cef_string_list_t arguments);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Add an argument to the end of the command line.
|
/// Add an argument to the end of the command line.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* append_argument)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* append_argument)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* argument);
|
const cef_string_t* argument);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Insert a command before the current command. Common for debuggers, like
|
/// Insert a command before the current command. Common for debuggers, like
|
||||||
// "valgrind" or "gdb --args".
|
/// "valgrind" or "gdb --args".
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* prepend_wrapper)(struct _cef_command_line_t* self,
|
void(CEF_CALLBACK* prepend_wrapper)(struct _cef_command_line_t* self,
|
||||||
const cef_string_t* wrapper);
|
const cef_string_t* wrapper);
|
||||||
} cef_command_line_t;
|
} cef_command_line_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Create a new cef_command_line_t instance.
|
/// Create a new cef_command_line_t instance.
|
||||||
///
|
///
|
||||||
CEF_EXPORT cef_command_line_t* cef_command_line_create();
|
CEF_EXPORT cef_command_line_t* cef_command_line_create(void);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the singleton global cef_command_line_t object. The returned object
|
/// Returns the singleton global cef_command_line_t object. The returned object
|
||||||
// will be read-only.
|
/// will be read-only.
|
||||||
///
|
///
|
||||||
CEF_EXPORT cef_command_line_t* cef_command_line_get_global();
|
CEF_EXPORT cef_command_line_t* cef_command_line_get_global(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=75b5bd826645fabb12c16c938b2fc30ec1642b1c$
|
// $hash=a6442e6bc6e7d335717bf9fbcf7a6e061216d449$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_CONTEXT_MENU_HANDLER_CAPI_H_
|
||||||
@@ -52,44 +52,67 @@ extern "C" {
|
|||||||
struct _cef_context_menu_params_t;
|
struct _cef_context_menu_params_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Callback structure used for continuation of custom context menu display.
|
/// Callback structure used for continuation of custom context menu display.
|
||||||
///
|
///
|
||||||
typedef struct _cef_run_context_menu_callback_t {
|
typedef struct _cef_run_context_menu_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Complete context menu display by selecting the specified |command_id| and
|
/// Complete context menu display by selecting the specified |command_id| and
|
||||||
// |event_flags|.
|
/// |event_flags|.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_run_context_menu_callback_t* self,
|
void(CEF_CALLBACK* cont)(struct _cef_run_context_menu_callback_t* self,
|
||||||
int command_id,
|
int command_id,
|
||||||
cef_event_flags_t event_flags);
|
cef_event_flags_t event_flags);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Cancel context menu display.
|
/// Cancel context menu display.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cancel)(struct _cef_run_context_menu_callback_t* self);
|
void(CEF_CALLBACK* cancel)(struct _cef_run_context_menu_callback_t* self);
|
||||||
} cef_run_context_menu_callback_t;
|
} cef_run_context_menu_callback_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle context menu events. The functions of this
|
/// Callback structure used for continuation of custom quick menu display.
|
||||||
// structure will be called on the UI thread.
|
|
||||||
///
|
///
|
||||||
typedef struct _cef_context_menu_handler_t {
|
typedef struct _cef_run_quick_menu_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called before a context menu is displayed. |params| provides information
|
/// Complete quick menu display by selecting the specified |command_id| and
|
||||||
// about the context menu state. |model| initially contains the default
|
/// |event_flags|.
|
||||||
// context menu. The |model| can be cleared to show no context menu or
|
///
|
||||||
// modified to show a custom menu. Do not keep references to |params| or
|
void(CEF_CALLBACK* cont)(struct _cef_run_quick_menu_callback_t* self,
|
||||||
// |model| outside of this callback.
|
int command_id,
|
||||||
|
cef_event_flags_t event_flags);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Cancel quick menu display.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* cancel)(struct _cef_run_quick_menu_callback_t* self);
|
||||||
|
} cef_run_quick_menu_callback_t;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Implement this structure to handle context menu events. The functions of
|
||||||
|
/// this structure will be called on the UI thread.
|
||||||
|
///
|
||||||
|
typedef struct _cef_context_menu_handler_t {
|
||||||
|
///
|
||||||
|
/// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called before a context menu is displayed. |params| provides information
|
||||||
|
/// about the context menu state. |model| initially contains the default
|
||||||
|
/// context menu. The |model| can be cleared to show no context menu or
|
||||||
|
/// modified to show a custom menu. Do not keep references to |params| or
|
||||||
|
/// |model| outside of this callback.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_before_context_menu)(
|
void(CEF_CALLBACK* on_before_context_menu)(
|
||||||
struct _cef_context_menu_handler_t* self,
|
struct _cef_context_menu_handler_t* self,
|
||||||
@@ -99,12 +122,12 @@ typedef struct _cef_context_menu_handler_t {
|
|||||||
struct _cef_menu_model_t* model);
|
struct _cef_menu_model_t* model);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to allow custom display of the context menu. |params| provides
|
/// Called to allow custom display of the context menu. |params| provides
|
||||||
// information about the context menu state. |model| contains the context menu
|
/// information about the context menu state. |model| contains the context
|
||||||
// model resulting from OnBeforeContextMenu. For custom display return true
|
/// menu model resulting from OnBeforeContextMenu. For custom display return
|
||||||
// (1) and execute |callback| either synchronously or asynchronously with the
|
/// true (1) and execute |callback| either synchronously or asynchronously
|
||||||
// selected command ID. For default display return false (0). Do not keep
|
/// with the selected command ID. For default display return false (0). Do not
|
||||||
// references to |params| or |model| outside of this callback.
|
/// keep references to |params| or |model| outside of this callback.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* run_context_menu)(
|
int(CEF_CALLBACK* run_context_menu)(
|
||||||
struct _cef_context_menu_handler_t* self,
|
struct _cef_context_menu_handler_t* self,
|
||||||
@@ -115,13 +138,13 @@ typedef struct _cef_context_menu_handler_t {
|
|||||||
struct _cef_run_context_menu_callback_t* callback);
|
struct _cef_run_context_menu_callback_t* callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to execute a command selected from the context menu. Return true (1)
|
/// Called to execute a command selected from the context menu. Return true
|
||||||
// if the command was handled or false (0) for the default implementation. See
|
/// (1) if the command was handled or false (0) for the default
|
||||||
// cef_menu_id_t for the command ids that have default implementations. All
|
/// implementation. See cef_menu_id_t for the command ids that have default
|
||||||
// user-defined command ids should be between MENU_ID_USER_FIRST and
|
/// implementations. All user-defined command ids should be between
|
||||||
// MENU_ID_USER_LAST. |params| will have the same values as what was passed to
|
/// MENU_ID_USER_FIRST and MENU_ID_USER_LAST. |params| will have the same
|
||||||
// on_before_context_menu(). Do not keep a reference to |params| outside of
|
/// values as what was passed to on_before_context_menu(). Do not keep a
|
||||||
// this callback.
|
/// reference to |params| outside of this callback.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_context_menu_command)(
|
int(CEF_CALLBACK* on_context_menu_command)(
|
||||||
struct _cef_context_menu_handler_t* self,
|
struct _cef_context_menu_handler_t* self,
|
||||||
@@ -132,173 +155,209 @@ typedef struct _cef_context_menu_handler_t {
|
|||||||
cef_event_flags_t event_flags);
|
cef_event_flags_t event_flags);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the context menu is dismissed irregardless of whether the menu
|
/// Called when the context menu is dismissed irregardless of whether the menu
|
||||||
// was NULL or a command was selected.
|
/// was canceled or a command was selected.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_context_menu_dismissed)(
|
void(CEF_CALLBACK* on_context_menu_dismissed)(
|
||||||
struct _cef_context_menu_handler_t* self,
|
struct _cef_context_menu_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
struct _cef_frame_t* frame);
|
struct _cef_frame_t* frame);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called to allow custom display of the quick menu for a windowless browser.
|
||||||
|
/// |location| is the top left corner of the selected region. |size| is the
|
||||||
|
/// size of the selected region. |edit_state_flags| is a combination of flags
|
||||||
|
/// that represent the state of the quick menu. Return true (1) if the menu
|
||||||
|
/// will be handled and execute |callback| either synchronously or
|
||||||
|
/// asynchronously with the selected command ID. Return false (0) to cancel
|
||||||
|
/// the menu.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* run_quick_menu)(
|
||||||
|
struct _cef_context_menu_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
struct _cef_frame_t* frame,
|
||||||
|
const cef_point_t* location,
|
||||||
|
const cef_size_t* size,
|
||||||
|
cef_quick_menu_edit_state_flags_t edit_state_flags,
|
||||||
|
struct _cef_run_quick_menu_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called to execute a command selected from the quick menu for a windowless
|
||||||
|
/// browser. Return true (1) if the command was handled or false (0) for the
|
||||||
|
/// default implementation. See cef_menu_id_t for command IDs that have
|
||||||
|
/// default implementations.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* on_quick_menu_command)(
|
||||||
|
struct _cef_context_menu_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
struct _cef_frame_t* frame,
|
||||||
|
int command_id,
|
||||||
|
cef_event_flags_t event_flags);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the quick menu for a windowless browser is dismissed
|
||||||
|
/// irregardless of whether the menu was canceled or a command was selected.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* on_quick_menu_dismissed)(
|
||||||
|
struct _cef_context_menu_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
struct _cef_frame_t* frame);
|
||||||
} cef_context_menu_handler_t;
|
} cef_context_menu_handler_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Provides information about the context menu state. The ethods of this
|
/// Provides information about the context menu state. The functions of this
|
||||||
// structure can only be accessed on browser process the UI thread.
|
/// structure can only be accessed on browser process the UI thread.
|
||||||
///
|
///
|
||||||
typedef struct _cef_context_menu_params_t {
|
typedef struct _cef_context_menu_params_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the X coordinate of the mouse where the context menu was invoked.
|
/// Returns the X coordinate of the mouse where the context menu was invoked.
|
||||||
// Coords are relative to the associated RenderView's origin.
|
/// Coords are relative to the associated RenderView's origin.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_xcoord)(struct _cef_context_menu_params_t* self);
|
int(CEF_CALLBACK* get_xcoord)(struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the Y coordinate of the mouse where the context menu was invoked.
|
/// Returns the Y coordinate of the mouse where the context menu was invoked.
|
||||||
// Coords are relative to the associated RenderView's origin.
|
/// Coords are relative to the associated RenderView's origin.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_ycoord)(struct _cef_context_menu_params_t* self);
|
int(CEF_CALLBACK* get_ycoord)(struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns flags representing the type of node that the context menu was
|
/// Returns flags representing the type of node that the context menu was
|
||||||
// invoked on.
|
/// invoked on.
|
||||||
///
|
///
|
||||||
cef_context_menu_type_flags_t(CEF_CALLBACK* get_type_flags)(
|
cef_context_menu_type_flags_t(CEF_CALLBACK* get_type_flags)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the URL of the link, if any, that encloses the node that the
|
/// Returns the URL of the link, if any, that encloses the node that the
|
||||||
// context menu was invoked on.
|
/// context menu was invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_link_url)(
|
cef_string_userfree_t(CEF_CALLBACK* get_link_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the link URL, if any, to be used ONLY for "copy link address". We
|
/// Returns the link URL, if any, to be used ONLY for "copy link address". We
|
||||||
// don't validate this field in the frontend process.
|
/// don't validate this field in the frontend process.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_unfiltered_link_url)(
|
cef_string_userfree_t(CEF_CALLBACK* get_unfiltered_link_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the source URL, if any, for the element that the context menu was
|
/// Returns the source URL, if any, for the element that the context menu was
|
||||||
// invoked on. Example of elements with source URLs are img, audio, and video.
|
/// invoked on. Example of elements with source URLs are img, audio, and
|
||||||
|
/// video.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_source_url)(
|
cef_string_userfree_t(CEF_CALLBACK* get_source_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the context menu was invoked on an image which has non-
|
/// Returns true (1) if the context menu was invoked on an image which has
|
||||||
// NULL contents.
|
/// non-NULL contents.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* has_image_contents)(
|
int(CEF_CALLBACK* has_image_contents)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the title text or the alt text if the context menu was invoked on
|
/// Returns the title text or the alt text if the context menu was invoked on
|
||||||
// an image.
|
/// an image.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_title_text)(
|
cef_string_userfree_t(CEF_CALLBACK* get_title_text)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the URL of the top level page that the context menu was invoked on.
|
/// Returns the URL of the top level page that the context menu was invoked
|
||||||
|
/// on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_page_url)(
|
cef_string_userfree_t(CEF_CALLBACK* get_page_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the URL of the subframe that the context menu was invoked on.
|
/// Returns the URL of the subframe that the context menu was invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_frame_url)(
|
cef_string_userfree_t(CEF_CALLBACK* get_frame_url)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the character encoding of the subframe that the context menu was
|
/// Returns the character encoding of the subframe that the context menu was
|
||||||
// invoked on.
|
/// invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_frame_charset)(
|
cef_string_userfree_t(CEF_CALLBACK* get_frame_charset)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the type of context node that the context menu was invoked on.
|
/// Returns the type of context node that the context menu was invoked on.
|
||||||
///
|
///
|
||||||
cef_context_menu_media_type_t(CEF_CALLBACK* get_media_type)(
|
cef_context_menu_media_type_t(CEF_CALLBACK* get_media_type)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns flags representing the actions supported by the media element, if
|
/// Returns flags representing the actions supported by the media element, if
|
||||||
// any, that the context menu was invoked on.
|
/// any, that the context menu was invoked on.
|
||||||
///
|
///
|
||||||
cef_context_menu_media_state_flags_t(CEF_CALLBACK* get_media_state_flags)(
|
cef_context_menu_media_state_flags_t(CEF_CALLBACK* get_media_state_flags)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the text of the selection, if any, that the context menu was
|
/// Returns the text of the selection, if any, that the context menu was
|
||||||
// invoked on.
|
/// invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_selection_text)(
|
cef_string_userfree_t(CEF_CALLBACK* get_selection_text)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the text of the misspelled word, if any, that the context menu was
|
/// Returns the text of the misspelled word, if any, that the context menu was
|
||||||
// invoked on.
|
/// invoked on.
|
||||||
///
|
///
|
||||||
// The resulting string must be freed by calling cef_string_userfree_free().
|
// The resulting string must be freed by calling cef_string_userfree_free().
|
||||||
cef_string_userfree_t(CEF_CALLBACK* get_misspelled_word)(
|
cef_string_userfree_t(CEF_CALLBACK* get_misspelled_word)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if suggestions exist, false (0) otherwise. Fills in
|
/// Returns true (1) if suggestions exist, false (0) otherwise. Fills in
|
||||||
// |suggestions| from the spell check service for the misspelled word if there
|
/// |suggestions| from the spell check service for the misspelled word if
|
||||||
// is one.
|
/// there is one.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* get_dictionary_suggestions)(
|
int(CEF_CALLBACK* get_dictionary_suggestions)(
|
||||||
struct _cef_context_menu_params_t* self,
|
struct _cef_context_menu_params_t* self,
|
||||||
cef_string_list_t suggestions);
|
cef_string_list_t suggestions);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the context menu was invoked on an editable node.
|
/// Returns true (1) if the context menu was invoked on an editable node.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_editable)(struct _cef_context_menu_params_t* self);
|
int(CEF_CALLBACK* is_editable)(struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the context menu was invoked on an editable node where
|
/// Returns true (1) if the context menu was invoked on an editable node where
|
||||||
// spell-check is enabled.
|
/// spell-check is enabled.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_spell_check_enabled)(
|
int(CEF_CALLBACK* is_spell_check_enabled)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns flags representing the actions supported by the editable node, if
|
/// Returns flags representing the actions supported by the editable node, if
|
||||||
// any, that the context menu was invoked on.
|
/// any, that the context menu was invoked on.
|
||||||
///
|
///
|
||||||
cef_context_menu_edit_state_flags_t(CEF_CALLBACK* get_edit_state_flags)(
|
cef_context_menu_edit_state_flags_t(CEF_CALLBACK* get_edit_state_flags)(
|
||||||
struct _cef_context_menu_params_t* self);
|
struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns true (1) if the context menu contains items specified by the
|
/// Returns true (1) if the context menu contains items specified by the
|
||||||
// renderer process (for example, plugin placeholder or pepper plugin menu
|
/// renderer process.
|
||||||
// items).
|
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_custom_menu)(struct _cef_context_menu_params_t* self);
|
int(CEF_CALLBACK* is_custom_menu)(struct _cef_context_menu_params_t* self);
|
||||||
|
|
||||||
///
|
|
||||||
// Returns true (1) if the context menu was invoked from a pepper plugin.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* is_pepper_menu)(struct _cef_context_menu_params_t* self);
|
|
||||||
} cef_context_menu_params_t;
|
} cef_context_menu_params_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=48b5fa68109eed1ea30fa0c805218ebd258c0573$
|
// $hash=f0ac9ba987d32a55b57d09acbdd2ff58f15c61b8$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_COOKIE_CAPI_H_
|
||||||
@@ -52,40 +52,29 @@ struct _cef_delete_cookies_callback_t;
|
|||||||
struct _cef_set_cookie_callback_t;
|
struct _cef_set_cookie_callback_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure used for managing cookies. The functions of this structure may be
|
/// Structure used for managing cookies. The functions of this structure may be
|
||||||
// called on any thread unless otherwise indicated.
|
/// called on any thread unless otherwise indicated.
|
||||||
///
|
///
|
||||||
typedef struct _cef_cookie_manager_t {
|
typedef struct _cef_cookie_manager_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Set the schemes supported by this manager. The default schemes ("http",
|
/// Visit all cookies on the UI thread. The returned cookies are ordered by
|
||||||
// "https", "ws" and "wss") will always be supported. If |callback| is non-
|
/// longest path, then by earliest creation date. Returns false (0) if cookies
|
||||||
// NULL it will be executed asnychronously on the IO thread after the change
|
/// cannot be accessed.
|
||||||
// has been applied. Must be called before any cookies are accessed.
|
|
||||||
///
|
|
||||||
void(CEF_CALLBACK* set_supported_schemes)(
|
|
||||||
struct _cef_cookie_manager_t* self,
|
|
||||||
cef_string_list_t schemes,
|
|
||||||
struct _cef_completion_callback_t* callback);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Visit all cookies on the IO thread. The returned cookies are ordered by
|
|
||||||
// longest path, then by earliest creation date. Returns false (0) if cookies
|
|
||||||
// cannot be accessed.
|
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* visit_all_cookies)(struct _cef_cookie_manager_t* self,
|
int(CEF_CALLBACK* visit_all_cookies)(struct _cef_cookie_manager_t* self,
|
||||||
struct _cef_cookie_visitor_t* visitor);
|
struct _cef_cookie_visitor_t* visitor);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Visit a subset of cookies on the IO thread. The results are filtered by the
|
/// Visit a subset of cookies on the UI thread. The results are filtered by
|
||||||
// given url scheme, host, domain and path. If |includeHttpOnly| is true (1)
|
/// the given url scheme, host, domain and path. If |includeHttpOnly| is true
|
||||||
// HTTP-only cookies will also be included in the results. The returned
|
/// (1) HTTP-only cookies will also be included in the results. The returned
|
||||||
// cookies are ordered by longest path, then by earliest creation date.
|
/// cookies are ordered by longest path, then by earliest creation date.
|
||||||
// Returns false (0) if cookies cannot be accessed.
|
/// Returns false (0) if cookies cannot be accessed.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* visit_url_cookies)(struct _cef_cookie_manager_t* self,
|
int(CEF_CALLBACK* visit_url_cookies)(struct _cef_cookie_manager_t* self,
|
||||||
const cef_string_t* url,
|
const cef_string_t* url,
|
||||||
@@ -93,13 +82,13 @@ typedef struct _cef_cookie_manager_t {
|
|||||||
struct _cef_cookie_visitor_t* visitor);
|
struct _cef_cookie_visitor_t* visitor);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Sets a cookie given a valid URL and explicit user-provided cookie
|
/// Sets a cookie given a valid URL and explicit user-provided cookie
|
||||||
// attributes. This function expects each attribute to be well-formed. It will
|
/// attributes. This function expects each attribute to be well-formed. It
|
||||||
// check for disallowed characters (e.g. the ';' character is disallowed
|
/// will check for disallowed characters (e.g. the ';' character is disallowed
|
||||||
// within the cookie value attribute) and fail without setting the cookie if
|
/// within the cookie value attribute) and fail without setting the cookie if
|
||||||
// such characters are found. If |callback| is non-NULL it will be executed
|
/// such characters are found. If |callback| is non-NULL it will be executed
|
||||||
// asnychronously on the IO thread after the cookie has been set. Returns
|
/// asnychronously on the UI thread after the cookie has been set. Returns
|
||||||
// false (0) if an invalid URL is specified or if cookies cannot be accessed.
|
/// false (0) if an invalid URL is specified or if cookies cannot be accessed.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* set_cookie)(struct _cef_cookie_manager_t* self,
|
int(CEF_CALLBACK* set_cookie)(struct _cef_cookie_manager_t* self,
|
||||||
const cef_string_t* url,
|
const cef_string_t* url,
|
||||||
@@ -107,15 +96,15 @@ typedef struct _cef_cookie_manager_t {
|
|||||||
struct _cef_set_cookie_callback_t* callback);
|
struct _cef_set_cookie_callback_t* callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Delete all cookies that match the specified parameters. If both |url| and
|
/// Delete all cookies that match the specified parameters. If both |url| and
|
||||||
// |cookie_name| values are specified all host and domain cookies matching
|
/// |cookie_name| values are specified all host and domain cookies matching
|
||||||
// both will be deleted. If only |url| is specified all host cookies (but not
|
/// both will be deleted. If only |url| is specified all host cookies (but not
|
||||||
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
|
/// domain cookies) irrespective of path will be deleted. If |url| is NULL all
|
||||||
// cookies for all hosts and domains will be deleted. If |callback| is non-
|
/// cookies for all hosts and domains will be deleted. If |callback| is non-
|
||||||
// NULL it will be executed asnychronously on the IO thread after the cookies
|
/// NULL it will be executed asnychronously on the UI thread after the cookies
|
||||||
// have been deleted. Returns false (0) if a non-NULL invalid URL is specified
|
/// have been deleted. Returns false (0) if a non-NULL invalid URL is
|
||||||
// or if cookies cannot be accessed. Cookies can alternately be deleted using
|
/// specified or if cookies cannot be accessed. Cookies can alternately be
|
||||||
// the Visit*Cookies() functions.
|
/// deleted using the Visit*Cookies() functions.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* delete_cookies)(
|
int(CEF_CALLBACK* delete_cookies)(
|
||||||
struct _cef_cookie_manager_t* self,
|
struct _cef_cookie_manager_t* self,
|
||||||
@@ -124,81 +113,41 @@ typedef struct _cef_cookie_manager_t {
|
|||||||
struct _cef_delete_cookies_callback_t* callback);
|
struct _cef_delete_cookies_callback_t* callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Sets the directory path that will be used for storing cookie data. If
|
/// Flush the backing store (if any) to disk. If |callback| is non-NULL it
|
||||||
// |path| is NULL data will be stored in memory only. Otherwise, data will be
|
/// will be executed asnychronously on the UI thread after the flush is
|
||||||
// stored at the specified |path|. To persist session cookies (cookies without
|
/// complete. Returns false (0) if cookies cannot be accessed.
|
||||||
// an expiry date or validity interval) set |persist_session_cookies| to true
|
|
||||||
// (1). Session cookies are generally intended to be transient and most Web
|
|
||||||
// browsers do not persist them. If |callback| is non-NULL it will be executed
|
|
||||||
// asnychronously on the IO thread after the manager's storage has been
|
|
||||||
// initialized. Returns false (0) if cookies cannot be accessed.
|
|
||||||
///
|
|
||||||
int(CEF_CALLBACK* set_storage_path)(
|
|
||||||
struct _cef_cookie_manager_t* self,
|
|
||||||
const cef_string_t* path,
|
|
||||||
int persist_session_cookies,
|
|
||||||
struct _cef_completion_callback_t* callback);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Flush the backing store (if any) to disk. If |callback| is non-NULL it will
|
|
||||||
// be executed asnychronously on the IO thread after the flush is complete.
|
|
||||||
// Returns false (0) if cookies cannot be accessed.
|
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* flush_store)(struct _cef_cookie_manager_t* self,
|
int(CEF_CALLBACK* flush_store)(struct _cef_cookie_manager_t* self,
|
||||||
struct _cef_completion_callback_t* callback);
|
struct _cef_completion_callback_t* callback);
|
||||||
} cef_cookie_manager_t;
|
} cef_cookie_manager_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns the global cookie manager. By default data will be stored at
|
/// Returns the global cookie manager. By default data will be stored at
|
||||||
// CefSettings.cache_path if specified or in memory otherwise. If |callback| is
|
/// cef_settings_t.cache_path if specified or in memory otherwise. If |callback|
|
||||||
// non-NULL it will be executed asnychronously on the IO thread after the
|
/// is non-NULL it will be executed asnychronously on the UI thread after the
|
||||||
// manager's storage has been initialized. Using this function is equivalent to
|
/// manager's storage has been initialized. Using this function is equivalent to
|
||||||
// calling cef_request_tContext::cef_request_context_get_global_context()->get_d
|
/// calling cef_request_context_t::cef_request_context_get_global_context()-
|
||||||
// efault_cookie_manager().
|
/// >GetDefaultCookieManager().
|
||||||
///
|
///
|
||||||
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
|
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
|
||||||
struct _cef_completion_callback_t* callback);
|
struct _cef_completion_callback_t* callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Returns a cookie manager that neither stores nor retrieves cookies. All usage
|
/// Structure to implement for visiting cookie values. The functions of this
|
||||||
// of cookies will be blocked including cookies accessed via the network
|
/// structure will always be called on the UI thread.
|
||||||
// (request/response headers), via JavaScript (document.cookie), and via
|
|
||||||
// cef_cookie_manager_t functions. No cookies will be displayed in DevTools. If
|
|
||||||
// you wish to only block cookies sent via the network use the
|
|
||||||
// cef_request_tHandler CanGetCookies and CanSetCookie functions instead.
|
|
||||||
///
|
|
||||||
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_blocking_manager();
|
|
||||||
|
|
||||||
///
|
|
||||||
// Creates a new cookie manager. If |path| is NULL data will be stored in memory
|
|
||||||
// only. Otherwise, data will be stored at the specified |path|. To persist
|
|
||||||
// session cookies (cookies without an expiry date or validity interval) set
|
|
||||||
// |persist_session_cookies| to true (1). Session cookies are generally intended
|
|
||||||
// to be transient and most Web browsers do not persist them. If |callback| is
|
|
||||||
// non-NULL it will be executed asnychronously on the IO thread after the
|
|
||||||
// manager's storage has been initialized.
|
|
||||||
///
|
|
||||||
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
|
|
||||||
const cef_string_t* path,
|
|
||||||
int persist_session_cookies,
|
|
||||||
struct _cef_completion_callback_t* callback);
|
|
||||||
|
|
||||||
///
|
|
||||||
// Structure to implement for visiting cookie values. The functions of this
|
|
||||||
// structure will always be called on the IO thread.
|
|
||||||
///
|
///
|
||||||
typedef struct _cef_cookie_visitor_t {
|
typedef struct _cef_cookie_visitor_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Method that will be called once for each cookie. |count| is the 0-based
|
/// Method that will be called once for each cookie. |count| is the 0-based
|
||||||
// index for the current cookie. |total| is the total number of cookies. Set
|
/// index for the current cookie. |total| is the total number of cookies. Set
|
||||||
// |deleteCookie| to true (1) to delete the cookie currently being visited.
|
/// |deleteCookie| to true (1) to delete the cookie currently being visited.
|
||||||
// Return false (0) to stop visiting cookies. This function may never be
|
/// Return false (0) to stop visiting cookies. This function may never be
|
||||||
// called if no cookies are found.
|
/// called if no cookies are found.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* visit)(struct _cef_cookie_visitor_t* self,
|
int(CEF_CALLBACK* visit)(struct _cef_cookie_visitor_t* self,
|
||||||
const struct _cef_cookie_t* cookie,
|
const struct _cef_cookie_t* cookie,
|
||||||
@@ -208,36 +157,36 @@ typedef struct _cef_cookie_visitor_t {
|
|||||||
} cef_cookie_visitor_t;
|
} cef_cookie_visitor_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure to implement to be notified of asynchronous completion via
|
/// Structure to implement to be notified of asynchronous completion via
|
||||||
// cef_cookie_manager_t::set_cookie().
|
/// cef_cookie_manager_t::set_cookie().
|
||||||
///
|
///
|
||||||
typedef struct _cef_set_cookie_callback_t {
|
typedef struct _cef_set_cookie_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Method that will be called upon completion. |success| will be true (1) if
|
/// Method that will be called upon completion. |success| will be true (1) if
|
||||||
// the cookie was set successfully.
|
/// the cookie was set successfully.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_complete)(struct _cef_set_cookie_callback_t* self,
|
void(CEF_CALLBACK* on_complete)(struct _cef_set_cookie_callback_t* self,
|
||||||
int success);
|
int success);
|
||||||
} cef_set_cookie_callback_t;
|
} cef_set_cookie_callback_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Structure to implement to be notified of asynchronous completion via
|
/// Structure to implement to be notified of asynchronous completion via
|
||||||
// cef_cookie_manager_t::delete_cookies().
|
/// cef_cookie_manager_t::delete_cookies().
|
||||||
///
|
///
|
||||||
typedef struct _cef_delete_cookies_callback_t {
|
typedef struct _cef_delete_cookies_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Method that will be called upon completion. |num_deleted| will be the
|
/// Method that will be called upon completion. |num_deleted| will be the
|
||||||
// number of cookies that were deleted.
|
/// number of cookies that were deleted.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_complete)(struct _cef_delete_cookies_callback_t* self,
|
void(CEF_CALLBACK* on_complete)(struct _cef_delete_cookies_callback_t* self,
|
||||||
int num_deleted);
|
int num_deleted);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=d8c4816346fdf48b987c88a94c51c9d67624abe0$
|
// $hash=4e76f0bd07a6814bf05cdb7b39ba24a88c7c2e55$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_CRASH_UTIL_CAPI_H_
|
||||||
@@ -47,99 +47,102 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Crash reporting is configured using an INI-style config file named
|
/// Crash reporting is configured using an INI-style config file named
|
||||||
// "crash_reporter.cfg". On Windows and Linux this file must be placed next to
|
/// "crash_reporter.cfg". On Windows and Linux this file must be placed next to
|
||||||
// the main application executable. On macOS this file must be placed in the
|
/// the main application executable. On macOS this file must be placed in the
|
||||||
// top-level app bundle Resources directory (e.g.
|
/// top-level app bundle Resources directory (e.g.
|
||||||
// "<appname>.app/Contents/Resources"). File contents are as follows:
|
/// "<appname>.app/Contents/Resources"). File contents are as follows:
|
||||||
//
|
|
||||||
// # Comments start with a hash character and must be on their own line.
|
|
||||||
//
|
|
||||||
// [Config]
|
|
||||||
// ProductName=<Value of the "prod" crash key; defaults to "cef">
|
|
||||||
// ProductVersion=<Value of the "ver" crash key; defaults to the CEF version>
|
|
||||||
// AppName=<Windows only; App-specific folder name component for storing crash
|
|
||||||
// information; default to "CEF">
|
|
||||||
// ExternalHandler=<Windows only; Name of the external handler exe to use
|
|
||||||
// instead of re-launching the main exe; default to empty>
|
|
||||||
// BrowserCrashForwardingEnabled=<macOS only; True if browser process crashes
|
|
||||||
// should be forwarded to the system crash
|
|
||||||
// reporter; default to false>
|
|
||||||
// ServerURL=<crash server URL; default to empty>
|
|
||||||
// RateLimitEnabled=<True if uploads should be rate limited; default to true>
|
|
||||||
// MaxUploadsPerDay=<Max uploads per 24 hours, used if rate limit is enabled;
|
|
||||||
// default to 5>
|
|
||||||
// MaxDatabaseSizeInMb=<Total crash report disk usage greater than this value
|
|
||||||
// will cause older reports to be deleted; default to 20>
|
|
||||||
// MaxDatabaseAgeInDays=<Crash reports older than this value will be deleted;
|
|
||||||
// default to 5>
|
|
||||||
//
|
|
||||||
// [CrashKeys]
|
|
||||||
// my_key1=<small|medium|large>
|
|
||||||
// my_key2=<small|medium|large>
|
|
||||||
//
|
|
||||||
// Config section:
|
|
||||||
//
|
|
||||||
// If "ProductName" and/or "ProductVersion" are set then the specified values
|
|
||||||
// will be included in the crash dump metadata. On macOS if these values are set
|
|
||||||
// to NULL then they will be retrieved from the Info.plist file using the
|
|
||||||
// "CFBundleName" and "CFBundleShortVersionString" keys respectively.
|
|
||||||
//
|
|
||||||
// If "AppName" is set on Windows then crash report information (metrics,
|
|
||||||
// database and dumps) will be stored locally on disk under the
|
|
||||||
// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other
|
|
||||||
// platforms the CefSettings.user_data_path value will be used.
|
|
||||||
//
|
|
||||||
// If "ExternalHandler" is set on Windows then the specified exe will be
|
|
||||||
// launched as the crashpad-handler instead of re-launching the main process
|
|
||||||
// exe. The value can be an absolute path or a path relative to the main exe
|
|
||||||
// directory. On Linux the CefSettings.browser_subprocess_path value will be
|
|
||||||
// used. On macOS the existing subprocess app bundle will be used.
|
|
||||||
//
|
|
||||||
// If "BrowserCrashForwardingEnabled" is set to true (1) on macOS then browser
|
|
||||||
// process crashes will be forwarded to the system crash reporter. This results
|
|
||||||
// in the crash UI dialog being displayed to the user and crash reports being
|
|
||||||
// logged under "~/Library/Logs/DiagnosticReports". Forwarding of crash reports
|
|
||||||
// from non-browser processes and Debug builds is always disabled.
|
|
||||||
//
|
|
||||||
// If "ServerURL" is set then crashes will be uploaded as a multi-part POST
|
|
||||||
// request to the specified URL. Otherwise, reports will only be stored locally
|
|
||||||
// on disk.
|
|
||||||
//
|
|
||||||
// If "RateLimitEnabled" is set to true (1) then crash report uploads will be
|
|
||||||
// rate limited as follows:
|
|
||||||
// 1. If "MaxUploadsPerDay" is set to a positive value then at most the
|
|
||||||
// specified number of crashes will be uploaded in each 24 hour period.
|
|
||||||
// 2. If crash upload fails due to a network or server error then an
|
|
||||||
// incremental backoff delay up to a maximum of 24 hours will be applied for
|
|
||||||
// retries.
|
|
||||||
// 3. If a backoff delay is applied and "MaxUploadsPerDay" is > 1 then the
|
|
||||||
// "MaxUploadsPerDay" value will be reduced to 1 until the client is
|
|
||||||
// restarted. This helps to avoid an upload flood when the network or
|
|
||||||
// server error is resolved.
|
|
||||||
// Rate limiting is not supported on Linux.
|
|
||||||
//
|
|
||||||
// If "MaxDatabaseSizeInMb" is set to a positive value then crash report storage
|
|
||||||
// on disk will be limited to that size in megabytes. For example, on Windows
|
|
||||||
// each dump is about 600KB so a "MaxDatabaseSizeInMb" value of 20 equates to
|
|
||||||
// about 34 crash reports stored on disk. Not supported on Linux.
|
|
||||||
//
|
|
||||||
// If "MaxDatabaseAgeInDays" is set to a positive value then crash reports older
|
|
||||||
// than the specified age in days will be deleted. Not supported on Linux.
|
|
||||||
//
|
|
||||||
// CrashKeys section:
|
|
||||||
//
|
|
||||||
// A maximum of 26 crash keys of each size can be specified for use by the
|
|
||||||
// application. Crash key values will be truncated based on the specified size
|
|
||||||
// (small = 64 bytes, medium = 256 bytes, large = 1024 bytes). The value of
|
|
||||||
// crash keys can be set from any thread or process using the
|
|
||||||
// CefSetCrashKeyValue function. These key/value pairs will be sent to the crash
|
|
||||||
// server along with the crash dump file.
|
|
||||||
///
|
///
|
||||||
CEF_EXPORT int cef_crash_reporting_enabled();
|
/// <pre>
|
||||||
|
/// # Comments start with a hash character and must be on their own line.
|
||||||
|
///
|
||||||
|
/// [Config]
|
||||||
|
/// ProductName=<Value of the "prod" crash key; defaults to "cef">
|
||||||
|
/// ProductVersion=<Value of the "ver" crash key; defaults to the CEF version>
|
||||||
|
/// AppName=<Windows only; App-specific folder name component for storing crash
|
||||||
|
/// information; default to "CEF">
|
||||||
|
/// ExternalHandler=<Windows only; Name of the external handler exe to use
|
||||||
|
/// instead of re-launching the main exe; default to empty>
|
||||||
|
/// BrowserCrashForwardingEnabled=<macOS only; True if browser process crashes
|
||||||
|
/// should be forwarded to the system crash
|
||||||
|
/// reporter; default to false>
|
||||||
|
/// ServerURL=<crash server URL; default to empty>
|
||||||
|
/// RateLimitEnabled=<True if uploads should be rate limited; default to true>
|
||||||
|
/// MaxUploadsPerDay=<Max uploads per 24 hours, used if rate limit is enabled;
|
||||||
|
/// default to 5>
|
||||||
|
/// MaxDatabaseSizeInMb=<Total crash report disk usage greater than this value
|
||||||
|
/// will cause older reports to be deleted; default to 20>
|
||||||
|
/// MaxDatabaseAgeInDays=<Crash reports older than this value will be deleted;
|
||||||
|
/// default to 5>
|
||||||
|
///
|
||||||
|
/// [CrashKeys]
|
||||||
|
/// my_key1=<small|medium|large>
|
||||||
|
/// my_key2=<small|medium|large>
|
||||||
|
/// </pre>
|
||||||
|
///
|
||||||
|
/// <b>Config section:</b>
|
||||||
|
///
|
||||||
|
/// If "ProductName" and/or "ProductVersion" are set then the specified values
|
||||||
|
/// will be included in the crash dump metadata. On macOS if these values are
|
||||||
|
/// set to NULL then they will be retrieved from the Info.plist file using the
|
||||||
|
/// "CFBundleName" and "CFBundleShortVersionString" keys respectively.
|
||||||
|
///
|
||||||
|
/// If "AppName" is set on Windows then crash report information (metrics,
|
||||||
|
/// database and dumps) will be stored locally on disk under the
|
||||||
|
/// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other
|
||||||
|
/// platforms the cef_settings_t.root_cache_path value will be used.
|
||||||
|
///
|
||||||
|
/// If "ExternalHandler" is set on Windows then the specified exe will be
|
||||||
|
/// launched as the crashpad-handler instead of re-launching the main process
|
||||||
|
/// exe. The value can be an absolute path or a path relative to the main exe
|
||||||
|
/// directory. On Linux the cef_settings_t.browser_subprocess_path value will be
|
||||||
|
/// used. On macOS the existing subprocess app bundle will be used.
|
||||||
|
///
|
||||||
|
/// If "BrowserCrashForwardingEnabled" is set to true (1) on macOS then browser
|
||||||
|
/// process crashes will be forwarded to the system crash reporter. This results
|
||||||
|
/// in the crash UI dialog being displayed to the user and crash reports being
|
||||||
|
/// logged under "~/Library/Logs/DiagnosticReports". Forwarding of crash reports
|
||||||
|
/// from non-browser processes and Debug builds is always disabled.
|
||||||
|
///
|
||||||
|
/// If "ServerURL" is set then crashes will be uploaded as a multi-part POST
|
||||||
|
/// request to the specified URL. Otherwise, reports will only be stored locally
|
||||||
|
/// on disk.
|
||||||
|
///
|
||||||
|
/// If "RateLimitEnabled" is set to true (1) then crash report uploads will be
|
||||||
|
/// rate limited as follows:
|
||||||
|
/// 1. If "MaxUploadsPerDay" is set to a positive value then at most the
|
||||||
|
/// specified number of crashes will be uploaded in each 24 hour period.
|
||||||
|
/// 2. If crash upload fails due to a network or server error then an
|
||||||
|
/// incremental backoff delay up to a maximum of 24 hours will be applied
|
||||||
|
/// for retries.
|
||||||
|
/// 3. If a backoff delay is applied and "MaxUploadsPerDay" is > 1 then the
|
||||||
|
/// "MaxUploadsPerDay" value will be reduced to 1 until the client is
|
||||||
|
/// restarted. This helps to avoid an upload flood when the network or
|
||||||
|
/// server error is resolved.
|
||||||
|
/// Rate limiting is not supported on Linux.
|
||||||
|
///
|
||||||
|
/// If "MaxDatabaseSizeInMb" is set to a positive value then crash report
|
||||||
|
/// storage on disk will be limited to that size in megabytes. For example, on
|
||||||
|
/// Windows each dump is about 600KB so a "MaxDatabaseSizeInMb" value of 20
|
||||||
|
/// equates to about 34 crash reports stored on disk. Not supported on Linux.
|
||||||
|
///
|
||||||
|
/// If "MaxDatabaseAgeInDays" is set to a positive value then crash reports
|
||||||
|
/// older than the specified age in days will be deleted. Not supported on
|
||||||
|
/// Linux.
|
||||||
|
///
|
||||||
|
/// <b>CrashKeys section:</b>
|
||||||
|
///
|
||||||
|
/// A maximum of 26 crash keys of each size can be specified for use by the
|
||||||
|
/// application. Crash key values will be truncated based on the specified size
|
||||||
|
/// (small = 64 bytes, medium = 256 bytes, large = 1024 bytes). The value of
|
||||||
|
/// crash keys can be set from any thread or process using the
|
||||||
|
/// CefSetCrashKeyValue function. These key/value pairs will be sent to the
|
||||||
|
/// crash server along with the crash dump file.
|
||||||
|
///
|
||||||
|
CEF_EXPORT int cef_crash_reporting_enabled(void);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Sets or clears a specific key-value pair from the crash metadata.
|
/// Sets or clears a specific key-value pair from the crash metadata.
|
||||||
///
|
///
|
||||||
CEF_EXPORT void cef_set_crash_key_value(const cef_string_t* key,
|
CEF_EXPORT void cef_set_crash_key_value(const cef_string_t* key,
|
||||||
const cef_string_t* value);
|
const cef_string_t* value);
|
||||||
|
|||||||
148
include/capi/cef_devtools_message_observer_capi.h
Normal file
148
include/capi/cef_devtools_message_observer_capi.h
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||||
|
// Framework nor the names of its contributors may be used to endorse
|
||||||
|
// or promote products derived from this software without specific prior
|
||||||
|
// written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool and should not edited
|
||||||
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
|
// more information.
|
||||||
|
//
|
||||||
|
// $hash=c46c975e4826d9f58a208b2efe7c417e1ffdba51$
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
|
||||||
|
#define CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/capi/cef_base_capi.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct _cef_browser_t;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Callback structure for cef_browser_host_t::AddDevToolsMessageObserver. The
|
||||||
|
/// functions of this structure will be called on the browser process UI thread.
|
||||||
|
///
|
||||||
|
typedef struct _cef_dev_tools_message_observer_t {
|
||||||
|
///
|
||||||
|
/// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Method that will be called on receipt of a DevTools protocol message.
|
||||||
|
/// |browser| is the originating browser instance. |message| is a UTF8-encoded
|
||||||
|
/// JSON dictionary representing either a function result or an event.
|
||||||
|
/// |message| is only valid for the scope of this callback and should be
|
||||||
|
/// copied if necessary. Return true (1) if the message was handled or false
|
||||||
|
/// (0) if the message should be further processed and passed to the
|
||||||
|
/// OnDevToolsMethodResult or OnDevToolsEvent functions as appropriate.
|
||||||
|
///
|
||||||
|
/// Method result dictionaries include an "id" (int) value that identifies the
|
||||||
|
/// orginating function call sent from
|
||||||
|
/// cef_browser_host_t::SendDevToolsMessage, and optionally either a "result"
|
||||||
|
/// (dictionary) or "error" (dictionary) value. The "error" dictionary will
|
||||||
|
/// contain "code" (int) and "message" (string) values. Event dictionaries
|
||||||
|
/// include a "function" (string) value and optionally a "params" (dictionary)
|
||||||
|
/// value. See the DevTools protocol documentation at
|
||||||
|
/// https://chromedevtools.github.io/devtools-protocol/ for details of
|
||||||
|
/// supported function calls and the expected "result" or "params" dictionary
|
||||||
|
/// contents. JSON dictionaries can be parsed using the CefParseJSON function
|
||||||
|
/// if desired, however be aware of performance considerations when parsing
|
||||||
|
/// large messages (some of which may exceed 1MB in size).
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* on_dev_tools_message)(
|
||||||
|
struct _cef_dev_tools_message_observer_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
const void* message,
|
||||||
|
size_t message_size);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Method that will be called after attempted execution of a DevTools
|
||||||
|
/// protocol function. |browser| is the originating browser instance.
|
||||||
|
/// |message_id| is the "id" value that identifies the originating function
|
||||||
|
/// call message. If the function succeeded |success| will be true (1) and
|
||||||
|
/// |result| will be the UTF8-encoded JSON "result" dictionary value (which
|
||||||
|
/// may be NULL). If the function failed |success| will be false (0) and
|
||||||
|
/// |result| will be the UTF8-encoded JSON "error" dictionary value. |result|
|
||||||
|
/// is only valid for the scope of this callback and should be copied if
|
||||||
|
/// necessary. See the OnDevToolsMessage documentation for additional details
|
||||||
|
/// on |result| contents.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* on_dev_tools_method_result)(
|
||||||
|
struct _cef_dev_tools_message_observer_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
int message_id,
|
||||||
|
int success,
|
||||||
|
const void* result,
|
||||||
|
size_t result_size);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Method that will be called on receipt of a DevTools protocol event.
|
||||||
|
/// |browser| is the originating browser instance. |function| is the
|
||||||
|
/// "function" value. |params| is the UTF8-encoded JSON "params" dictionary
|
||||||
|
/// value (which may be NULL). |params| is only valid for the scope of this
|
||||||
|
/// callback and should be copied if necessary. See the OnDevToolsMessage
|
||||||
|
/// documentation for additional details on |params| contents.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* on_dev_tools_event)(
|
||||||
|
struct _cef_dev_tools_message_observer_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
const cef_string_t* method,
|
||||||
|
const void* params,
|
||||||
|
size_t params_size);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Method that will be called when the DevTools agent has attached. |browser|
|
||||||
|
/// is the originating browser instance. This will generally occur in response
|
||||||
|
/// to the first message sent while the agent is detached.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* on_dev_tools_agent_attached)(
|
||||||
|
struct _cef_dev_tools_message_observer_t* self,
|
||||||
|
struct _cef_browser_t* browser);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Method that will be called when the DevTools agent has detached. |browser|
|
||||||
|
/// is the originating browser instance. Any function results that were
|
||||||
|
/// pending before the agent became detached will not be delivered, and any
|
||||||
|
/// active event subscriptions will be canceled.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* on_dev_tools_agent_detached)(
|
||||||
|
struct _cef_dev_tools_message_observer_t* self,
|
||||||
|
struct _cef_browser_t* browser);
|
||||||
|
} cef_dev_tools_message_observer_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CAPI_CEF_DEVTOOLS_MESSAGE_OBSERVER_CAPI_H_
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=23627ca4a51e3256889c05360f3fe143172f4ad6$
|
// $hash=9028da9ae0b0f9a2f98b163fdb98c2d999368cf8$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DIALOG_HANDLER_CAPI_H_
|
||||||
@@ -48,55 +48,58 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Callback structure for asynchronous continuation of file dialog requests.
|
/// Callback structure for asynchronous continuation of file dialog requests.
|
||||||
///
|
///
|
||||||
typedef struct _cef_file_dialog_callback_t {
|
typedef struct _cef_file_dialog_callback_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Continue the file selection. |selected_accept_filter| should be the 0-based
|
/// Continue the file selection. |file_paths| should be a single value or a
|
||||||
// index of the value selected from the accept filters array passed to
|
/// list of values depending on the dialog mode. An NULL |file_paths| value is
|
||||||
// cef_dialog_handler_t::OnFileDialog. |file_paths| should be a single value
|
/// treated the same as calling cancel().
|
||||||
// or a list of values depending on the dialog mode. An NULL |file_paths|
|
|
||||||
// value is treated the same as calling cancel().
|
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cont)(struct _cef_file_dialog_callback_t* self,
|
void(CEF_CALLBACK* cont)(struct _cef_file_dialog_callback_t* self,
|
||||||
int selected_accept_filter,
|
|
||||||
cef_string_list_t file_paths);
|
cef_string_list_t file_paths);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Cancel the file selection.
|
/// Cancel the file selection.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* cancel)(struct _cef_file_dialog_callback_t* self);
|
void(CEF_CALLBACK* cancel)(struct _cef_file_dialog_callback_t* self);
|
||||||
} cef_file_dialog_callback_t;
|
} cef_file_dialog_callback_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle dialog events. The functions of this
|
/// Implement this structure to handle dialog events. The functions of this
|
||||||
// structure will be called on the browser process UI thread.
|
/// structure will be called on the browser process UI thread.
|
||||||
///
|
///
|
||||||
typedef struct _cef_dialog_handler_t {
|
typedef struct _cef_dialog_handler_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to run a file chooser dialog. |mode| represents the type of dialog
|
/// Called to run a file chooser dialog. |mode| represents the type of dialog
|
||||||
// to display. |title| to the title to be used for the dialog and may be NULL
|
/// to display. |title| to the title to be used for the dialog and may be NULL
|
||||||
// to show the default title ("Open" or "Save" depending on the mode).
|
/// to show the default title ("Open" or "Save" depending on the mode).
|
||||||
// |default_file_path| is the path with optional directory and/or file name
|
/// |default_file_path| is the path with optional directory and/or file name
|
||||||
// component that should be initially selected in the dialog. |accept_filters|
|
/// component that should be initially selected in the dialog.
|
||||||
// are used to restrict the selectable file types and may any combination of
|
/// |accept_filters| are used to restrict the selectable file types and may be
|
||||||
// (a) valid lower-cased MIME types (e.g. "text/*" or "image/*"), (b)
|
/// any combination of valid lower-cased MIME types (e.g. "text/*" or
|
||||||
// individual file extensions (e.g. ".txt" or ".png"), or (c) combined
|
/// "image/*") and individual file extensions (e.g. ".txt" or ".png").
|
||||||
// description and file extension delimited using "|" and ";" (e.g. "Image
|
/// |accept_extensions| provides the semicolon-delimited expansion of MIME
|
||||||
// Types|.png;.gif;.jpg"). |selected_accept_filter| is the 0-based index of
|
/// types to file extensions (if known, or NULL string otherwise).
|
||||||
// the filter that should be selected by default. To display a custom dialog
|
/// |accept_descriptions| provides the descriptions for MIME types (if known,
|
||||||
// return true (1) and execute |callback| either inline or at a later time. To
|
/// or NULL string otherwise). For example, the "image/*" mime type might have
|
||||||
// display the default dialog return false (0).
|
/// extensions ".png;.jpg;.bmp;..." and description "Image Files".
|
||||||
|
/// |accept_filters|, |accept_extensions| and |accept_descriptions| will all
|
||||||
|
/// be the same size. To display a custom dialog return true (1) and execute
|
||||||
|
/// |callback| either inline or at a later time. To display the default dialog
|
||||||
|
/// return false (0). If this function returns false (0) it may be called an
|
||||||
|
/// additional time for the same dialog (both before and after MIME type
|
||||||
|
/// expansion).
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_file_dialog)(
|
int(CEF_CALLBACK* on_file_dialog)(
|
||||||
struct _cef_dialog_handler_t* self,
|
struct _cef_dialog_handler_t* self,
|
||||||
@@ -105,7 +108,8 @@ typedef struct _cef_dialog_handler_t {
|
|||||||
const cef_string_t* title,
|
const cef_string_t* title,
|
||||||
const cef_string_t* default_file_path,
|
const cef_string_t* default_file_path,
|
||||||
cef_string_list_t accept_filters,
|
cef_string_list_t accept_filters,
|
||||||
int selected_accept_filter,
|
cef_string_list_t accept_extensions,
|
||||||
|
cef_string_list_t accept_descriptions,
|
||||||
struct _cef_file_dialog_callback_t* callback);
|
struct _cef_file_dialog_callback_t* callback);
|
||||||
} cef_dialog_handler_t;
|
} cef_dialog_handler_t;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Marshall A. Greenblatt. All rights reserved.
|
// Copyright (c) 2025 Marshall A. Greenblatt. All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=f6998cb056849c4d73f47142988bd4900784e0c6$
|
// $hash=c2c7970554008e70a24403198a08155354773bd3$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_
|
||||||
@@ -49,17 +49,17 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to browser display state.
|
/// Implement this structure to handle events related to browser display state.
|
||||||
// The functions of this structure will be called on the UI thread.
|
/// The functions of this structure will be called on the UI thread.
|
||||||
///
|
///
|
||||||
typedef struct _cef_display_handler_t {
|
typedef struct _cef_display_handler_t {
|
||||||
///
|
///
|
||||||
// Base structure.
|
/// Base structure.
|
||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when a frame's address has changed.
|
/// Called when a frame's address has changed.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_address_change)(struct _cef_display_handler_t* self,
|
void(CEF_CALLBACK* on_address_change)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
@@ -67,25 +67,29 @@ typedef struct _cef_display_handler_t {
|
|||||||
const cef_string_t* url);
|
const cef_string_t* url);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the page title changes.
|
/// Called when the page title changes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_title_change)(struct _cef_display_handler_t* self,
|
void(CEF_CALLBACK* on_title_change)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
const cef_string_t* title);
|
const cef_string_t* title);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the page icon changes.
|
/// Called when the page icon changes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_favicon_urlchange)(struct _cef_display_handler_t* self,
|
void(CEF_CALLBACK* on_favicon_urlchange)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
cef_string_list_t icon_urls);
|
cef_string_list_t icon_urls);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when web content in the page has toggled fullscreen mode. If
|
/// Called when web content in the page has toggled fullscreen mode. If
|
||||||
// |fullscreen| is true (1) the content will automatically be sized to fill
|
/// |fullscreen| is true (1) the content will automatically be sized to fill
|
||||||
// the browser content area. If |fullscreen| is false (0) the content will
|
/// the browser content area. If |fullscreen| is false (0) the content will
|
||||||
// automatically return to its original size and position. The client is
|
/// automatically return to its original size and position. With Alloy style
|
||||||
// responsible for resizing the browser if desired.
|
/// the client is responsible for triggering the fullscreen transition (for
|
||||||
|
/// example, by calling cef_window_t::SetFullscreen when using Views). With
|
||||||
|
/// Chrome style the fullscreen transition will be triggered automatically.
|
||||||
|
/// The cef_window_delegate_t::OnWindowFullscreenTransition function will be
|
||||||
|
/// called during the fullscreen transition for notification purposes.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_fullscreen_mode_change)(
|
void(CEF_CALLBACK* on_fullscreen_mode_change)(
|
||||||
struct _cef_display_handler_t* self,
|
struct _cef_display_handler_t* self,
|
||||||
@@ -93,28 +97,28 @@ typedef struct _cef_display_handler_t {
|
|||||||
int fullscreen);
|
int fullscreen);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the browser is about to display a tooltip. |text| contains the
|
/// Called when the browser is about to display a tooltip. |text| contains the
|
||||||
// text that will be displayed in the tooltip. To handle the display of the
|
/// text that will be displayed in the tooltip. To handle the display of the
|
||||||
// tooltip yourself return true (1). Otherwise, you can optionally modify
|
/// tooltip yourself return true (1). Otherwise, you can optionally modify
|
||||||
// |text| and then return false (0) to allow the browser to display the
|
/// |text| and then return false (0) to allow the browser to display the
|
||||||
// tooltip. When window rendering is disabled the application is responsible
|
/// tooltip. When window rendering is disabled the application is responsible
|
||||||
// for drawing tooltips and the return value is ignored.
|
/// for drawing tooltips and the return value is ignored.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_tooltip)(struct _cef_display_handler_t* self,
|
int(CEF_CALLBACK* on_tooltip)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
cef_string_t* text);
|
cef_string_t* text);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the browser receives a status message. |value| contains the
|
/// Called when the browser receives a status message. |value| contains the
|
||||||
// text that will be displayed in the status message.
|
/// text that will be displayed in the status message.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_status_message)(struct _cef_display_handler_t* self,
|
void(CEF_CALLBACK* on_status_message)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
const cef_string_t* value);
|
const cef_string_t* value);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called to display a console message. Return true (1) to stop the message
|
/// Called to display a console message. Return true (1) to stop the message
|
||||||
// from being output to the console.
|
/// from being output to the console.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_console_message)(struct _cef_display_handler_t* self,
|
int(CEF_CALLBACK* on_console_message)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
@@ -124,23 +128,46 @@ typedef struct _cef_display_handler_t {
|
|||||||
int line);
|
int line);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when auto-resize is enabled via
|
/// Called when auto-resize is enabled via
|
||||||
// cef_browser_host_t::SetAutoResizeEnabled and the contents have auto-
|
/// cef_browser_host_t::SetAutoResizeEnabled and the contents have auto-
|
||||||
// resized. |new_size| will be the desired size in view coordinates. Return
|
/// resized. |new_size| will be the desired size in view coordinates. Return
|
||||||
// true (1) if the resize was handled or false (0) for default handling.
|
/// true (1) if the resize was handled or false (0) for default handling.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* on_auto_resize)(struct _cef_display_handler_t* self,
|
int(CEF_CALLBACK* on_auto_resize)(struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
const cef_size_t* new_size);
|
const cef_size_t* new_size);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called when the overall page loading progress has changed. |progress|
|
/// Called when the overall page loading progress has changed. |progress|
|
||||||
// ranges from 0.0 to 1.0.
|
/// ranges from 0.0 to 1.0.
|
||||||
///
|
///
|
||||||
void(CEF_CALLBACK* on_loading_progress_change)(
|
void(CEF_CALLBACK* on_loading_progress_change)(
|
||||||
struct _cef_display_handler_t* self,
|
struct _cef_display_handler_t* self,
|
||||||
struct _cef_browser_t* browser,
|
struct _cef_browser_t* browser,
|
||||||
double progress);
|
double progress);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the browser's cursor has changed. If |type| is CT_CUSTOM then
|
||||||
|
/// |custom_cursor_info| will be populated with the custom cursor information.
|
||||||
|
/// Return true (1) if the cursor change was handled or false (0) for default
|
||||||
|
/// handling.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* on_cursor_change)(
|
||||||
|
struct _cef_display_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
cef_cursor_handle_t cursor,
|
||||||
|
cef_cursor_type_t type,
|
||||||
|
const cef_cursor_info_t* custom_cursor_info);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Called when the browser's access to an audio and/or video source has
|
||||||
|
/// changed.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* on_media_access_change)(
|
||||||
|
struct _cef_display_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser,
|
||||||
|
int has_video_access,
|
||||||
|
int has_audio_access);
|
||||||
} cef_display_handler_t;
|
} cef_display_handler_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user