Skip to content

Add Http Global State Object - #10188

Merged
bors-servo merged 1 commit into
servo:masterfrom
cbrewster:http-global-state
Mar 26, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
cbrewster:http-global-state

Conversation

@cbrewster

Copy link
Copy Markdown
Contributor

This adds a new HttpState object which holds common http state(#10175). This reduces the amount of work that is required to add extra things to the Http state.

The HttpState object currently holds:

hsts_list: Arc::new(RwLock::new(HSTSList::new())),
cookie_jar: Arc::new(RwLock::new(CookieStorage::new())),
auth_cache: Arc::new(RwLock::new(HashMap::new())),

This change is Reviewable

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 25, 2016
@jdm jdm assigned jdm and unassigned nox Mar 25, 2016
@jdm

jdm commented Mar 25, 2016

Copy link
Copy Markdown
Member

Thanks for doing this! These changes propagate the new type to places where I don't think it really adds clarity, so the majority of my comments are pointing out places where I find the older code clearer.
-S-awaiting-review +S-needs-code-changes


Reviewed 4 of 4 files at r1.
Review status: all files reviewed at latest revision, 12 unresolved discussions.


components/net/http_loader.rs, line 81 [r1] (raw file):
This doesn't need to be an Arc.


components/net/http_loader.rs, line 366 [r1] (raw file):
Let's revert this change. It makes more sense to pass a reference to the specific field we care about.


components/net/http_loader.rs, line 375 [r1] (raw file):
Let's revert this change.


components/net/http_loader.rs, line 391 [r1] (raw file):
Revert.


components/net/http_loader.rs, line 403 [r1] (raw file):
Revert.


components/net/http_loader.rs, line 520 [r1] (raw file):
Revert.


components/net/http_loader.rs, line 530 [r1] (raw file):
Revert.


components/net/http_loader.rs, line 563 [r1] (raw file):
Revert.


components/net/http_loader.rs, line 597 [r1] (raw file):
Revert.


components/net/resource_thread.rs, line 278 [r1] (raw file):
I think I'd still prefer to keep these fields and make a new HttpState instance when calling http_loader::factory instead.


components/net/websocket_loader.rs, line 30 [r1] (raw file):
Let's revert this.


components/net/websocket_loader.rs, line 65 [r1] (raw file):
Revert.


Comments from the review on Reviewable.io

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 25, 2016
@cbrewster

Copy link
Copy Markdown
Contributor Author

No problem! Almost have all the changes made.


Review status: all files reviewed at latest revision, 12 unresolved discussions.


Comments from the review on Reviewable.io

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Mar 25, 2016
@cbrewster

Copy link
Copy Markdown
Contributor Author

Review status: 1 of 3 files reviewed at latest revision, 12 unresolved discussions.


components/net/http_loader.rs, line 81 [r1] (raw file):
Done.


Comments from the review on Reviewable.io

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 25, 2016
@jdm

jdm commented Mar 25, 2016

Copy link
Copy Markdown
Member

-S-awaiting-review +S-needs-code-changes


Reviewed 3 of 3 files at r2.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


components/net/http_loader.rs, line 81 [r2] (raw file):
I think taking an HttpState argument here still makes sense.


components/net/http_loader.rs, line 152 [r2] (raw file):
No need for Arc here.


Comments from the review on Reviewable.io

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Mar 25, 2016
@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-awaiting-review There is new code that needs to be reviewed. labels Mar 25, 2016
@jdm

jdm commented Mar 25, 2016

Copy link
Copy Markdown
Member

Please squash all commits as well when making the final change!
-S-awaiting-review +S-needs-code-changes +S-needs-squash


Reviewed 2 of 2 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


components/net/http_loader.rs, line 154 [r3] (raw file):
No need for Arc on any HttpState argument.


Comments from the review on Reviewable.io

@cbrewster

Copy link
Copy Markdown
Contributor Author

On that last change, the tests often pass the HttpState object into the load function and then use the HttpState object again within an assert. Would it be best to pass a ref of the object to the load function so the object is not moved?

Replace hsts_list, auth_cache, and cookie_jar with http_state

Reverted a few changes

Moved http_state back to factory
Removed unnecessary Arc

Removed Arc for http_state
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Mar 25, 2016
@cbrewster

Copy link
Copy Markdown
Contributor Author

Squashed and removed Arc for HttpState

@jdm

jdm commented Mar 26, 2016

Copy link
Copy Markdown
Member

@bors-servo: r+
Thanks for doing this cleanup!


Reviewed 2 of 2 files at r4.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from the review on Reviewable.io

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit b09570b has been approved by jdm

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit b09570b with merge d82f97a...

bors-servo pushed a commit that referenced this pull request Mar 26, 2016
Add Http Global State Object

This adds a new HttpState object which holds common http state(#10175). This reduces the amount of work that is required to add extra things to the Http state.

The HttpState object currently holds:
```
hsts_list: Arc::new(RwLock::new(HSTSList::new())),
cookie_jar: Arc::new(RwLock::new(CookieStorage::new())),
auth_cache: Arc::new(RwLock::new(HashMap::new())),
```

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10188)
<!-- Reviewable:end -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-squash Some (or all) of the commits in the PR should be combined. labels Mar 26, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor

@bors-servo
bors-servo merged commit b09570b into servo:master Mar 26, 2016
@cbrewster
cbrewster deleted the http-global-state branch March 26, 2016 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants