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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api_unittest.cc

Issue 10825127: Valgrind: Clean up leaks in callers to extension_function_test_utils::RunFunction. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 extension_function_test_utils::INCLUDE_INCOGNITO : 472 extension_function_test_utils::INCLUDE_INCOGNITO :
473 extension_function_test_utils::NONE; 473 extension_function_test_utils::NONE;
474 } 474 }
475 475
476 // extension_function_test_utils::RunFunction*() only uses browser for its 476 // extension_function_test_utils::RunFunction*() only uses browser for its
477 // profile(), so pass it the on-record browser so that it always uses the 477 // profile(), so pass it the on-record browser so that it always uses the
478 // on-record profile to match real-life behavior. 478 // on-record profile to match real-life behavior.
479 479
480 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function, 480 base::Value* RunFunctionAndReturnResult(UIThreadExtensionFunction* function,
481 const std::string& args) { 481 const std::string& args) {
482 scoped_refptr<UIThreadExtensionFunction> delete_function(function);
482 SetUpExtensionFunction(function); 483 SetUpExtensionFunction(function);
483 return extension_function_test_utils::RunFunctionAndReturnSingleResult( 484 return extension_function_test_utils::RunFunctionAndReturnSingleResult(
484 function, args, browser(), GetFlags()); 485 function, args, browser(), GetFlags());
485 } 486 }
486 487
487 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function, 488 std::string RunFunctionAndReturnError(UIThreadExtensionFunction* function,
488 const std::string& args) { 489 const std::string& args) {
490 scoped_refptr<UIThreadExtensionFunction> delete_function(function);
489 SetUpExtensionFunction(function); 491 SetUpExtensionFunction(function);
490 return extension_function_test_utils::RunFunctionAndReturnError( 492 return extension_function_test_utils::RunFunctionAndReturnError(
491 function, args, browser(), GetFlags()); 493 function, args, browser(), GetFlags());
492 } 494 }
493 495
494 bool RunFunctionAndReturnString(UIThreadExtensionFunction* function, 496 bool RunFunctionAndReturnString(UIThreadExtensionFunction* function,
495 const std::string& args, 497 const std::string& args,
496 std::string* result_string) { 498 std::string* result_string) {
497 SetUpExtensionFunction(function); 499 SetUpExtensionFunction(function);
498 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(function, args)); 500 scoped_ptr<base::Value> result(RunFunctionAndReturnResult(function, args));
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 " \"state\": {" 2156 " \"state\": {"
2155 " \"previous\": \"in_progress\"," 2157 " \"previous\": \"in_progress\","
2156 " \"current\": \"complete\"}}]", 2158 " \"current\": \"complete\"}}]",
2157 result_id, 2159 result_id,
2158 GetFilename("on_record.txt.crdownload").c_str(), 2160 GetFilename("on_record.txt.crdownload").c_str(),
2159 GetFilename("on_record.txt").c_str()))); 2161 GetFilename("on_record.txt").c_str())));
2160 std::string disk_data; 2162 std::string disk_data;
2161 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); 2163 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data));
2162 EXPECT_STREQ(kPayloadData, disk_data.c_str()); 2164 EXPECT_STREQ(kPayloadData, disk_data.c_str());
2163 } 2165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698