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

Side by Side Diff: chrome/browser/extensions/api/page_capture/page_capture_api.cc

Issue 2684843004: Avoid AddRef'ing non-thread-safe ref count on PageCaptureSaveAsMHTML (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/page_capture/page_capture_api.h" 5 #include "chrome/browser/extensions/api/page_capture/page_capture_api.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 19 matching lines...) Expand all
30 30
31 namespace SaveAsMHTML = extensions::api::page_capture::SaveAsMHTML; 31 namespace SaveAsMHTML = extensions::api::page_capture::SaveAsMHTML;
32 32
33 namespace { 33 namespace {
34 34
35 const char kFileTooBigError[] = "The MHTML file generated is too big."; 35 const char kFileTooBigError[] = "The MHTML file generated is too big.";
36 const char kMHTMLGenerationFailedError[] = "Failed to generate MHTML."; 36 const char kMHTMLGenerationFailedError[] = "Failed to generate MHTML.";
37 const char kTemporaryFileError[] = "Failed to create a temporary file."; 37 const char kTemporaryFileError[] = "Failed to create a temporary file.";
38 const char kTabClosedError[] = "Cannot find the tab for this request."; 38 const char kTabClosedError[] = "Cannot find the tab for this request.";
39 39
40 void ClearFileReferenceOnIOThread(
41 scoped_refptr<storage::ShareableFileReference>) {}
42
40 } // namespace 43 } // namespace
41 44
42 static PageCaptureSaveAsMHTMLFunction::TestDelegate* test_delegate_ = NULL; 45 static PageCaptureSaveAsMHTMLFunction::TestDelegate* test_delegate_ = NULL;
43 46
44 PageCaptureSaveAsMHTMLFunction::PageCaptureSaveAsMHTMLFunction() { 47 PageCaptureSaveAsMHTMLFunction::PageCaptureSaveAsMHTMLFunction() {
45 } 48 }
46 49
47 PageCaptureSaveAsMHTMLFunction::~PageCaptureSaveAsMHTMLFunction() { 50 PageCaptureSaveAsMHTMLFunction::~PageCaptureSaveAsMHTMLFunction() {
48 if (mhtml_file_.get()) { 51 if (mhtml_file_.get()) {
49 storage::ShareableFileReference* to_release = mhtml_file_.get(); 52 BrowserThread::PostTask(
50 to_release->AddRef(); 53 BrowserThread::IO, FROM_HERE,
51 mhtml_file_ = NULL; 54 base::Bind(&ClearFileReferenceOnIOThread, base::Passed(&mhtml_file_)));
52 BrowserThread::ReleaseSoon(BrowserThread::IO, FROM_HERE, to_release);
53 } 55 }
54 } 56 }
55 57
56 void PageCaptureSaveAsMHTMLFunction::SetTestDelegate(TestDelegate* delegate) { 58 void PageCaptureSaveAsMHTMLFunction::SetTestDelegate(TestDelegate* delegate) {
57 test_delegate_ = delegate; 59 test_delegate_ = delegate;
58 } 60 }
59 61
60 bool PageCaptureSaveAsMHTMLFunction::RunAsync() { 62 bool PageCaptureSaveAsMHTMLFunction::RunAsync() {
61 params_ = SaveAsMHTML::Params::Create(*args_); 63 params_ = SaveAsMHTML::Params::Create(*args_);
62 EXTENSION_FUNCTION_VALIDATE(params_.get()); 64 EXTENSION_FUNCTION_VALIDATE(params_.get());
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 GetProfile(), 195 GetProfile(),
194 include_incognito(), 196 include_incognito(),
195 &browser, 197 &browser,
196 NULL, 198 NULL,
197 &web_contents, 199 &web_contents,
198 NULL)) { 200 NULL)) {
199 return NULL; 201 return NULL;
200 } 202 }
201 return web_contents; 203 return web_contents;
202 } 204 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698