Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2799)

Unified Diff: content/renderer/mojo_context_state.cc

Issue 2705073003: Remove ScopedVector from content/renderer/. (Closed)
Patch Set: Fix win trybots Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/mojo_context_state.cc
diff --git a/content/renderer/mojo_context_state.cc b/content/renderer/mojo_context_state.cc
index 16c802b2901f88a418ec7d4daff449a5dcb99eae..030c940bec3026fd0fce34557c007f0114dee7ff 100644
--- a/content/renderer/mojo_context_state.cc
+++ b/content/renderer/mojo_context_state.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "base/stl_util.h"
@@ -182,7 +183,7 @@ void MojoContextState::FetchModule(const std::string& id) {
DCHECK(fetched_modules_.find(id) == fetched_modules_.end());
fetched_modules_.insert(id);
ResourceFetcher* fetcher = ResourceFetcher::Create(url);
- module_fetchers_.push_back(fetcher);
+ module_fetchers_.push_back(base::WrapUnique(fetcher));
fetcher->Start(frame_,
blink::WebURLRequest::RequestContextScript,
blink::WebURLRequest::FrameTypeNone,
@@ -202,9 +203,14 @@ void MojoContextState::OnFetchModuleComplete(
DCHECK_EQ(module_prefix_ + id, response.url().string().utf8());
// We can't delete fetch right now as the arguments to this function come from
// it and are used below. Instead use a scope_ptr to cleanup.
- std::unique_ptr<ResourceFetcher> deleter(fetcher);
- module_fetchers_.weak_erase(
- std::find(module_fetchers_.begin(), module_fetchers_.end(), fetcher));
+ auto iter =
+ std::find_if(module_fetchers_.begin(), module_fetchers_.end(),
+ [fetcher](const std::unique_ptr<ResourceFetcher>& item) {
+ return item.get() == fetcher;
+ });
+ std::unique_ptr<ResourceFetcher> deleter = std::move(*iter);
+ module_fetchers_.erase(iter);
+
if (data.empty()) {
LOG(ERROR) << "Fetched empty source for module \"" << id << "\"";
return;

Powered by Google App Engine
This is Rietveld 408576698