| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0b88bbd commit 46cb0da
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -651,7 +651,9 @@ Http2Session::Http2Session(Environment* env, | |||
| 651 | 651 | { | |
| 652 | 652 | // Make the js_fields_ property accessible to JS land. | |
| 653 | 653 | Local<ArrayBuffer> ab = | |
| 654 | - ArrayBuffer::New(env->isolate(), js_fields_, kSessionUint8FieldCount); | ||
| 654 | + ArrayBuffer::New(env->isolate(), | ||
| 655 | + reinterpret_cast<uint8_t*>(&js_fields_), | ||
| 656 | + kSessionUint8FieldCount); | ||
| 655 | 657 | Local<Uint8Array> uint8_arr = | |
| 656 | 658 | Uint8Array::New(ab, 0, kSessionUint8FieldCount); | |
| 657 | 659 | USE(wrap->Set(env->context(), env->fields_string(), uint8_arr)); | |
@@ -1082,7 +1084,7 @@ int Http2Session::OnFrameNotSent(nghttp2_session* handle, | |||
| 1082 | 1084 | if (error_code == NGHTTP2_ERR_SESSION_CLOSING || | |
| 1083 | 1085 | error_code == NGHTTP2_ERR_STREAM_CLOSED || | |
| 1084 | 1086 | error_code == NGHTTP2_ERR_STREAM_CLOSING || | |
| 1085 | - session->js_fields_[kSessionFrameErrorListenerCount] == 0) { | ||
| 1087 | + session->js_fields_.frame_error_listener_count == 0) { | ||
| 1086 | 1088 | return 0; | |
| 1087 | 1089 | } | |
| 1088 | 1090 | ||
@@ -1388,7 +1390,7 @@ void Http2Session::HandleHeadersFrame(const nghttp2_frame* frame) { | |||
| 1388 | 1390 | // are considered advisory only, so this has no real effect other than to | |
| 1389 | 1391 | // simply let user code know that the priority has changed. | |
| 1390 | 1392 | void Http2Session::HandlePriorityFrame(const nghttp2_frame* frame) { | |
| 1391 | - if (js_fields_[kSessionPriorityListenerCount] == 0) return; | ||
| 1393 | + if (js_fields_.priority_listener_count == 0) return; | ||
| 1392 | 1394 | Isolate* isolate = env()->isolate(); | |
| 1393 | 1395 | HandleScope scope(isolate); | |
| 1394 | 1396 | Local<Context> context = env()->context(); | |
@@ -1458,7 +1460,7 @@ void Http2Session::HandleGoawayFrame(const nghttp2_frame* frame) { | |||
| 1458 | 1460 | ||
| 1459 | 1461 | // Called by OnFrameReceived when a complete ALTSVC frame has been received. | |
| 1460 | 1462 | void Http2Session::HandleAltSvcFrame(const nghttp2_frame* frame) { | |
| 1461 | - if (!(js_fields_[kBitfield] & (1 << kSessionHasAltsvcListeners))) return; | ||
| 1463 | + if (!(js_fields_.bitfield & (1 << kSessionHasAltsvcListeners))) return; | ||
| 1462 | 1464 | Isolate* isolate = env()->isolate(); | |
| 1463 | 1465 | HandleScope scope(isolate); | |
| 1464 | 1466 | Local<Context> context = env()->context(); | |
@@ -1537,7 +1539,7 @@ void Http2Session::HandlePingFrame(const nghttp2_frame* frame) { | |||
| 1537 | 1539 | return; | |
| 1538 | 1540 | } | |
| 1539 | 1541 | ||
| 1540 | - if (!(js_fields_[kBitfield] & (1 << kSessionHasPingListeners))) return; | ||
| 1542 | + if (!(js_fields_.bitfield & (1 << kSessionHasPingListeners))) return; | ||
| 1541 | 1543 | // Notify the session that a ping occurred | |
| 1542 | 1544 | arg = Buffer::Copy(env(), | |
| 1543 | 1545 | reinterpret_cast<const char*>(frame->ping.opaque_data), | |
@@ -1549,8 +1551,8 @@ void Http2Session::HandlePingFrame(const nghttp2_frame* frame) { | |||
| 1549 | 1551 | void Http2Session::HandleSettingsFrame(const nghttp2_frame* frame) { | |
| 1550 | 1552 | bool ack = frame->hd.flags & NGHTTP2_FLAG_ACK; | |
| 1551 | 1553 | if (!ack) { | |
| 1552 | - js_fields_[kBitfield] &= ~(1 << kSessionRemoteSettingsIsUpToDate); | ||
| 1553 | - if (!(js_fields_[kBitfield] & (1 << kSessionHasRemoteSettingsListeners))) | ||
| 1554 | + js_fields_.bitfield &= ~(1 << kSessionRemoteSettingsIsUpToDate); | ||
| 1555 | + if (!(js_fields_.bitfield & (1 << kSessionHasRemoteSettingsListeners))) | ||
| 1554 | 1556 | return; | |
| 1555 | 1557 | // This is not a SETTINGS acknowledgement, notify and return | |
| 1556 | 1558 | MakeCallback(env()->http2session_on_settings_function(), 0, nullptr); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -675,15 +675,23 @@ class Http2Stream::Provider::Stream : public Http2Stream::Provider { | |||
| 675 | 675 | void* user_data); | |
| 676 | 676 | }; | |
| 677 | 677 | ||
| 678 | + typedef struct { | ||
| 679 | + uint8_t bitfield; | ||
| 680 | + uint8_t priority_listener_count; | ||
| 681 | + uint8_t frame_error_listener_count; | ||
| 682 | + } SessionJSFields; | ||
| 683 | + | ||
| 678 | 684 | // Indices for js_fields_, which serves as a way to communicate data with JS | |
| 679 | 685 | // land fast. In particular, we store information about the number/presence | |
| 680 | 686 | // of certain event listeners in JS, and skip calls from C++ into JS if they | |
| 681 | 687 | // are missing. | |
| 682 | 688 | enum SessionUint8Fields { | |
| 683 | - kBitfield, // See below | ||
| 684 | - kSessionPriorityListenerCount, | ||
| 685 | - kSessionFrameErrorListenerCount, | ||
| 686 | - kSessionUint8FieldCount | ||
| 689 | + kBitfield = offsetof(SessionJSFields, bitfield), // See below | ||
| 690 | + kSessionPriorityListenerCount = | ||
| 691 | + offsetof(SessionJSFields, priority_listener_count), | ||
| 692 | + kSessionFrameErrorListenerCount = | ||
| 693 | + offsetof(SessionJSFields, frame_error_listener_count), | ||
| 694 | + kSessionUint8FieldCount = sizeof(SessionJSFields) | ||
| 687 | 695 | }; | |
| 688 | 696 | ||
| 689 | 697 | enum SessionBitfieldFlags { | |
@@ -972,7 +980,7 @@ class Http2Session : public AsyncWrap, public StreamListener { | |||
| 972 | 980 | nghttp2_session* session_; | |
| 973 | 981 | ||
| 974 | 982 | // JS-accessible numeric fields, as indexed by SessionUint8Fields. | |
| 975 | - uint8_t js_fields_[kSessionUint8FieldCount] = {}; | ||
| 983 | + SessionJSFields js_fields_ = {}; | ||
| 976 | 984 | ||
| 977 | 985 | // The session type: client or server | |
| 978 | 986 | nghttp2_session_type session_type_; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments