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

Cherry pick PR #1832: Add test cases for cobalt::loader::FetcherCache #2935

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cobalt/loader/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ target(gtest_target_type, "loader_test") {

sources = [
"blob_fetcher_test.cc",
"fetcher_cache_test.cc",
"fetcher_factory_test.cc",
"fetcher_test.h",
"file_fetcher_test.cc",
Expand All @@ -204,6 +205,7 @@ target(gtest_target_type, "loader_test") {
"//testing/gmock",
"//testing/gtest",
"//third_party/ots:ots",
"//url",
]

data_deps = [ ":copy_loader_test_data" ]
Expand Down
10 changes: 10 additions & 0 deletions cobalt/loader/fetcher_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ class FetcherCache : public base::RefCountedThreadSafe<FetcherCache> {
Loader::FetcherCreator GetFetcherCreator(
const GURL& url, const Loader::FetcherCreator& real_fetcher_creator);
void NotifyResourceRequested(const std::string& url);
size_t size() const {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
CHECK_EQ(thread_id_, SbThreadGetId());
return total_size_;
}
size_t capacity() const {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
CHECK_EQ(thread_id_, SbThreadGetId());
return capacity_;
}

// To signal the imminent destruction of this object. If everything is
// working as expected, there shouldn't be any other reference of this object,
Expand Down
Loading
Loading