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

Side by Side Diff: extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.cc

Issue 1864583006: Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h" 5 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h"
6 6
7 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/storage_partition.h"
8 #include "content/public/common/url_fetcher.h" 9 #include "content/public/common/url_fetcher.h"
9 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
10 #include "net/url_request/url_fetcher.h" 11 #include "net/url_request/url_fetcher.h"
11 12
12 WebUIURLFetcher::WebUIURLFetcher(content::BrowserContext* context, 13 WebUIURLFetcher::WebUIURLFetcher(content::BrowserContext* context,
13 int render_process_id, 14 int render_process_id,
14 int render_view_id, 15 int render_view_id,
15 const GURL& url, 16 const GURL& url,
16 const WebUILoadFileCallback& callback) 17 const WebUILoadFileCallback& callback)
17 : context_(context), 18 : context_(context),
18 render_process_id_(render_process_id), 19 render_process_id_(render_process_id),
19 render_view_id_(render_view_id), 20 render_view_id_(render_view_id),
20 url_(url), 21 url_(url),
21 callback_(callback) { 22 callback_(callback) {
22 } 23 }
23 24
24 WebUIURLFetcher::~WebUIURLFetcher() { 25 WebUIURLFetcher::~WebUIURLFetcher() {
25 } 26 }
26 27
27 void WebUIURLFetcher::Start() { 28 void WebUIURLFetcher::Start() {
28 fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this); 29 fetcher_ = net::URLFetcher::Create(url_, net::URLFetcher::GET, this);
29 fetcher_->SetRequestContext(context_->GetRequestContext()); 30 fetcher_->SetRequestContext(
31 content::BrowserContext::GetDefaultStoragePartition(context_)->
32 GetURLRequestContext());
30 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); 33 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
31 34
32 content::AssociateURLFetcherWithRenderFrame( 35 content::AssociateURLFetcherWithRenderFrame(
33 fetcher_.get(), url_, render_process_id_, render_view_id_); 36 fetcher_.get(), url_, render_process_id_, render_view_id_);
34 fetcher_->Start(); 37 fetcher_->Start();
35 } 38 }
36 39
37 void WebUIURLFetcher::OnURLFetchComplete(const net::URLFetcher* source) { 40 void WebUIURLFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
38 CHECK_EQ(fetcher_.get(), source); 41 CHECK_EQ(fetcher_.get(), source);
39 42
40 std::string data; 43 std::string data;
41 bool result = false; 44 bool result = false;
42 if (fetcher_->GetStatus().status() == net::URLRequestStatus::SUCCESS) { 45 if (fetcher_->GetStatus().status() == net::URLRequestStatus::SUCCESS) {
43 result = fetcher_->GetResponseAsString(&data); 46 result = fetcher_->GetResponseAsString(&data);
44 DCHECK(result); 47 DCHECK(result);
45 } 48 }
46 fetcher_.reset(); 49 fetcher_.reset();
47 // We cache the callback and reset it so that any references stored within it 50 // We cache the callback and reset it so that any references stored within it
48 // are destroyed at the end of the method. 51 // are destroyed at the end of the method.
49 auto callback_cache = callback_; 52 auto callback_cache = callback_;
50 callback_.Reset(); 53 callback_.Reset();
51 callback_cache.Run(result, data); 54 callback_cache.Run(result, data);
52 } 55 }
OLDNEW
« no previous file with comments | « extensions/browser/extensions_test.cc ('k') | extensions/shell/browser/api/identity/identity_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698