Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedreader repository moved into brave core #5142

Merged
merged 40 commits into from
May 5, 2020
Merged

Conversation

AndriusA
Copy link

@AndriusA AndriusA commented Apr 2, 2020

Resolves brave/brave-browser#8978
Resolves brave/brave-browser#7995

Submitter Checklist:

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@AndriusA
Copy link
Author

AndriusA commented Apr 7, 2020

SpeedReaderThrottle should use a previously loaded SpeedReaderWhitelist for both URL checking and transformations - fixing that is pending on #5085

@AndriusA AndriusA force-pushed the speedreader-rust branch 2 times, most recently from a64b3fc to 2c4a28f Compare April 8, 2020 18:59

if (is_mac || is_ios ) {
libs += [
"Security.framework"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this actually needed or was it just copied from another repo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied, not noticed issues without, removed now

speedreader_flags = ""
}

speedreader_shared_lib_install_name = ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stuff was never meant to be duplicated in other repos, in a follow up we need to reorganize this stuff

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reorganised some if it here, still need to resolve a linking issue on linux, can you take another look?

"src/errors.rs",
"src/lib.rs",
"src/speedreader.rs",
"../src/src/whitelist.rs",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there seem to be some missing inputs here like lolhtml.rs all inputs files must be listed or changes to them won't trigger a rebuild

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listed all ../lib/src files that should trigger a rebuild (examples, benches and tests not used in the browser build)

* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */'''
include_guard = "BRAVE_COMPONENTS_SPEEDREADER_RUST_FFI_INCLUDE_SPEEDREADER_FFI_H_"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this used for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this config controls how components/speedreader/rust/ffi/includes/speedreader_ffi.h is auto-generated (besides the auto-generated file having to be in output dir)

include_guard just specifies the full guard as per chromium's naming convention, since cbindgen doesn' know about the rest of the project structure


cbindgen::generate(crate_dir)
.expect("Unable to generate bindings")
.write_to_file("include/speedreader_ffi.h");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, is this a generated file? If so we need to change the way this works because generated files need to go in the output dir and they shouldn't be committed in the repo

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is, will try to figure out a way of controlling output path via gn

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introduced a new action template globally to handle this (and other crates). Bindings header does not strictly need to be auto-generated, but in all of our cases seem to be, only committed to source control instead of generating from source on-demand

"src/errors.rs",
"src/lib.rs",
"src/speedreader.rs",
"../src/src/whitelist.rs",
Copy link
Collaborator

@bridiver bridiver Apr 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also why is there a bunch of stuff in src/src instead of just src? Most of the files are also missing from the list of inputs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanting to keep the FFI part of the library separate from the logic, we discussed having brave/components/speedreader/rust/src and brave/components/speedreader/rust/ffi and Cargo package convention puts sources within src.

Happy to rename (src -> lib, so it would be lib/src?), but doesn't seem useful to just merge them

bool deserialize(const char* data, size_t data_size);

/// Checks if the provided URL matches whitelisted readable URLs.
bool ReadableURL(const std::string& url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this class is responsible for both whitelist and rewriting? Is it possible to split?
If we do, we can relax about creating multiple speedreaders inside throttles

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggested rename IsReadableURL

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed reason for joint responsibility, method renamed

void*),
void* output_sink_user_data);

static std::string TakeLastError();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious - is it needed? is it thread-safe?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ends up useful for logging and a baby step towards better error handling across the FFI boundary.

but yes, it is thread-safe in the sense that the error if any is stored in thread-local storage

@AndriusA AndriusA force-pushed the speedreader-rust branch 2 times, most recently from a023307 to c3e4097 Compare April 15, 2020 08:30
return engine_->matches(url.spec(), url.host(), url.host(),
false, "sub_frame", &explicit_cancel,
&saved_from_exception, &redirect);
std::unique_ptr<Rewriter> SpeedreaderWhitelist::MakeRewriter(const GURL& url) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for followup - seems like this method belongs in the SpeedreaderService along with IsWhitelisted/IsReadableURL

@@ -8,29 +8,54 @@
#include <utility>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for followup the name/class of this file should really be SpeedreaderWhitelistInstaller

@@ -23,8 +25,8 @@ class SpeedReaderThrottle : public blink::URLLoaderThrottle {
// |task_runner| is used to bind the right task runner for handling incoming
// IPC in SpeedReaderLoader. |task_runner| is supposed to be bound to the
// current sequence.
explicit SpeedReaderThrottle(
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
SpeedReaderThrottle(SpeedreaderWhitelist* whitelist,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for followup this should use the SpeadreaderService

@@ -7,6 +7,8 @@
#define BRAVE_COMPONENTS_SPEEDREADER_SPEEDREADER_THROTTLE_H_

#include "base/memory/weak_ptr.h"
#include "brave/components/speedreader/speedreader_switches.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't appear to be used here

@@ -7,6 +7,8 @@
#define BRAVE_COMPONENTS_SPEEDREADER_SPEEDREADER_THROTTLE_H_

#include "base/memory/weak_ptr.h"
#include "brave/components/speedreader/speedreader_switches.h"
#include "brave/components/speedreader/speedreader_whitelist.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a forward declaration

@bridiver
Copy link
Collaborator

bridiver commented May 5, 2020

unrelated travis npm security failure

@bridiver bridiver merged commit 3fa625c into master May 5, 2020
@bridiver bridiver deleted the speedreader-rust branch May 5, 2020 23:23
@bsclifton bsclifton added this to the 1.10.x - Nightly milestone May 6, 2020
@bsclifton
Copy link
Member

Added missing milestone

@bsclifton
Copy link
Member

bsclifton commented May 6, 2020

If uplifted, we'll need to also uplift #5469 and #5474

@petemill
Copy link
Member

petemill commented Jul 3, 2020

Ideally 3170a89 and eae930a would have been removed before this branch was merged to master - now everyone's brave-core clone will forever have an extra 147Mb in its .git folder!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bring SpeedReader +FFI repos into brave-core Define initial whitelist of URLs SpeedReader will handle
6 participants