| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3475f9b commit e92afd9
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -647,7 +647,9 @@ Http2Session::Http2Session(Environment* env, | |||
| 647 | 647 | { | |
| 648 | 648 | // Make the js_fields_ property accessible to JS land. | |
| 649 | 649 | Local<ArrayBuffer> ab = | |
| 650 | - ArrayBuffer::New(env->isolate(), js_fields_, kSessionUint8FieldCount); | ||
| 650 | + ArrayBuffer::New(env->isolate(), | ||
| 651 | + reinterpret_cast<uint8_t*>(&js_fields_), | ||
| 652 | + kSessionUint8FieldCount); | ||
| 651 | 653 | Local<Uint8Array> uint8_arr = | |
| 652 | 654 | Uint8Array::New(ab, 0, kSessionUint8FieldCount); | |
| 653 | 655 | USE(wrap->Set(env->context(), env->fields_string(), uint8_arr)); | |
@@ -1046,7 +1048,7 @@ int Http2Session::OnFrameNotSent(nghttp2_session* handle, | |||
| 1046 | 1048 | if (error_code == NGHTTP2_ERR_SESSION_CLOSING || | |
| 1047 | 1049 | error_code == NGHTTP2_ERR_STREAM_CLOSED || | |
| 1048 | 1050 | error_code == NGHTTP2_ERR_STREAM_CLOSING || | |
| 1049 | - session->js_fields_[kSessionFrameErrorListenerCount] == 0) { | ||
| 1051 | + session->js_fields_.frame_error_listener_count == 0) { | ||
| 1050 | 1052 | return 0; | |
| 1051 | 1053 | } | |
| 1052 | 1054 | ||
@@ -1349,7 +1351,7 @@ void Http2Session::HandleHeadersFrame(const nghttp2_frame* frame) { | |||
| 1349 | 1351 | // are considered advisory only, so this has no real effect other than to | |
| 1350 | 1352 | // simply let user code know that the priority has changed. | |
| 1351 | 1353 | void Http2Session::HandlePriorityFrame(const nghttp2_frame* frame) { | |
| 1352 | - if (js_fields_[kSessionPriorityListenerCount] == 0) return; | ||
| 1354 | + if (js_fields_.priority_listener_count == 0) return; | ||
| 1353 | 1355 | Isolate* isolate = env()->isolate(); | |
| 1354 | 1356 | HandleScope scope(isolate); | |
| 1355 | 1357 | Local<Context> context = env()->context(); | |
@@ -1418,7 +1420,7 @@ void Http2Session::HandleGoawayFrame(const nghttp2_frame* frame) { | |||
| 1418 | 1420 | ||
| 1419 | 1421 | // Called by OnFrameReceived when a complete ALTSVC frame has been received. | |
| 1420 | 1422 | void Http2Session::HandleAltSvcFrame(const nghttp2_frame* frame) { | |
| 1421 | - if (!(js_fields_[kBitfield] & (1 << kSessionHasAltsvcListeners))) return; | ||
| 1423 | + if (!(js_fields_.bitfield & (1 << kSessionHasAltsvcListeners))) return; | ||
| 1422 | 1424 | Isolate* isolate = env()->isolate(); | |
| 1423 | 1425 | HandleScope scope(isolate); | |
| 1424 | 1426 | Local<Context> context = env()->context(); | |
@@ -1497,7 +1499,7 @@ void Http2Session::HandlePingFrame(const nghttp2_frame* frame) { | |||
| 1497 | 1499 | return; | |
| 1498 | 1500 | } | |
| 1499 | 1501 | ||
| 1500 | - if (!(js_fields_[kBitfield] & (1 << kSessionHasPingListeners))) return; | ||
| 1502 | + if (!(js_fields_.bitfield & (1 << kSessionHasPingListeners))) return; | ||
| 1501 | 1503 | // Notify the session that a ping occurred | |
| 1502 | 1504 | arg = Buffer::Copy(env(), | |
| 1503 | 1505 | reinterpret_cast<const char*>(frame->ping.opaque_data), | |
@@ -1509,8 +1511,8 @@ void Http2Session::HandlePingFrame(const nghttp2_frame* frame) { | |||
| 1509 | 1511 | void Http2Session::HandleSettingsFrame(const nghttp2_frame* frame) { | |
| 1510 | 1512 | bool ack = frame->hd.flags & NGHTTP2_FLAG_ACK; | |
| 1511 | 1513 | if (!ack) { | |
| 1512 | - js_fields_[kBitfield] &= ~(1 << kSessionRemoteSettingsIsUpToDate); | ||
| 1513 | - if (!(js_fields_[kBitfield] & (1 << kSessionHasRemoteSettingsListeners))) | ||
| 1514 | + js_fields_.bitfield &= ~(1 << kSessionRemoteSettingsIsUpToDate); | ||
| 1515 | + if (!(js_fields_.bitfield & (1 << kSessionHasRemoteSettingsListeners))) | ||
| 1514 | 1516 | return; | |
| 1515 | 1517 | // This is not a SETTINGS acknowledgement, notify and return | |
| 1516 | 1518 | MakeCallback(env()->http2session_on_settings_function(), 0, nullptr); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -673,15 +673,23 @@ class Http2Stream::Provider::Stream : public Http2Stream::Provider { | |||
| 673 | 673 | void* user_data); | |
| 674 | 674 | }; | |
| 675 | 675 | ||
| 676 | + typedef struct { | ||
| 677 | + uint8_t bitfield; | ||
| 678 | + uint8_t priority_listener_count; | ||
| 679 | + uint8_t frame_error_listener_count; | ||
| 680 | + } SessionJSFields; | ||
| 681 | + | ||
| 676 | 682 | // Indices for js_fields_, which serves as a way to communicate data with JS | |
| 677 | 683 | // land fast. In particular, we store information about the number/presence | |
| 678 | 684 | // of certain event listeners in JS, and skip calls from C++ into JS if they | |
| 679 | 685 | // are missing. | |
| 680 | 686 | enum SessionUint8Fields { | |
| 681 | - kBitfield, // See below | ||
| 682 | - kSessionPriorityListenerCount, | ||
| 683 | - kSessionFrameErrorListenerCount, | ||
| 684 | - kSessionUint8FieldCount | ||
| 687 | + kBitfield = offsetof(SessionJSFields, bitfield), // See below | ||
| 688 | + kSessionPriorityListenerCount = | ||
| 689 | + offsetof(SessionJSFields, priority_listener_count), | ||
| 690 | + kSessionFrameErrorListenerCount = | ||
| 691 | + offsetof(SessionJSFields, frame_error_listener_count), | ||
| 692 | + kSessionUint8FieldCount = sizeof(SessionJSFields) | ||
| 685 | 693 | }; | |
| 686 | 694 | ||
| 687 | 695 | enum SessionBitfieldFlags { | |
@@ -968,7 +976,7 @@ class Http2Session : public AsyncWrap, public StreamListener { | |||
| 968 | 976 | nghttp2_session* session_; | |
| 969 | 977 | ||
| 970 | 978 | // JS-accessible numeric fields, as indexed by SessionUint8Fields. | |
| 971 | - uint8_t js_fields_[kSessionUint8FieldCount] = {}; | ||
| 979 | + SessionJSFields js_fields_ = {}; | ||
| 972 | 980 | ||
| 973 | 981 | // The session type: client or server | |
| 974 | 982 | nghttp2_session_type session_type_; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments