Remove experimental.record api completely
BUG=259492
[email protected]
Review URL: https://chromiumcodereview.appspot.com/21854002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215835 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/api/record/record_api.cc b/chrome/browser/extensions/api/record/record_api.cc
deleted file mode 100644
index b381316..0000000
--- a/chrome/browser/extensions/api/record/record_api.cc
+++ /dev/null
@@ -1,261 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/extensions/api/record/record_api.h"
-
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/memory/ref_counted.h"
-#include "base/process/kill.h"
-#include "base/process/launch.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_split.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/api/experimental_record.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/common/content_switches.h"
-
-namespace extensions {
-
-namespace record = api::experimental_record;
-
-ProcessStrategy::~ProcessStrategy() {}
-
-void ProductionProcessStrategy::RunProcess(const CommandLine& line,
- std::vector<std::string>* errors) {
- base::LaunchOptions options;
- base::ProcessHandle handle;
-
- base::LaunchProcess(line, options, &handle);
-
- int exit_code = 0;
-
- if (!base::WaitForExitCode(handle, &exit_code) || exit_code != 0)
- errors->push_back("Test browser exited abnormally");
-}
-
-RunPageCyclerFunction::RunPageCyclerFunction(ProcessStrategy* strategy)
- : repeat_count_(1), base_command_line_(*CommandLine::ForCurrentProcess()),
- process_strategy_(strategy) {}
-
-RunPageCyclerFunction::~RunPageCyclerFunction() {}
-
-bool RunPageCyclerFunction::RunImpl() {
- if (!ParseJSParameters())
- return false;
-
- // If we've had any errors reportable to the JS caller so far (in
- // parameter parsing) then return a list of such errors, else perform
- // RunTestBrowser on the BlockingPool.
- if (!errors_.empty()) {
- results_ = record::CaptureURLs::Results::Create(errors_);
- SendResponse(true);
- } else {
- content::BrowserThread::PostBlockingPoolTask(FROM_HERE,
- base::Bind(&RunPageCyclerFunction::RunTestBrowser, this));
- process_strategy_->PumpBlockingPool(); // Test purposes only.
- }
-
- return true;
-}
-
-CommandLine RunPageCyclerFunction::RemoveSwitches(const CommandLine& original,
- const std::vector<std::string>& to_remove) {
- std::vector<const char*> to_keep;
- const CommandLine::SwitchMap& current_switches = original.GetSwitches();
- CommandLine filtered(original.GetProgram());
-
- // Retain in |to_keep| all current swtiches *not* in |to_remove|.
- for (CommandLine::SwitchMap::const_iterator itr = current_switches.begin();
- itr != current_switches.end(); ++itr) {
- if (std::find(to_remove.begin(), to_remove.end(), (*itr).first) ==
- to_remove.end()) {
- to_keep.push_back((*itr).first.c_str());
- }
- }
-
- // Rely on std::vector keeping its contents in contiguous order.
- // (This is documented STL spec.)
- filtered.CopySwitchesFrom(original, &to_keep.front(), to_keep.size());
-
- return filtered;
-}
-
-// Runs on BlockingPool thread. Invoked from UI thread and passes back to
-// UI thread for |Final()| callback to JS side.
-void RunPageCyclerFunction::RunTestBrowser() {
- // Remove any current switch settings that would interfere with test browser
- // commandline setup.
- std::vector<std::string> remove_switches;
- remove_switches.push_back(switches::kUserDataDir);
- remove_switches.push_back(switches::kVisitURLs);
- remove_switches.push_back(switches::kPlaybackMode);
- remove_switches.push_back(switches::kRecordStats);
- remove_switches.push_back(switches::kLoadExtension);
-
- CommandLine line = RemoveSwitches(base_command_line_, remove_switches);
-
- // Add the user-data-dir switch, since this is common to both call types.
- line.AppendSwitchPath(switches::kUserDataDir, user_data_dir_);
-
- // Test browsers must run as if they are not in first-run mode
- line.AppendSwitch(switches::kNoFirstRun);
-
- // Create and fill a temp file to communicate the URL list to the test
- // browser.
- base::FilePath url_path;
- file_util::CreateTemporaryFile(&url_path);
- file_util::WriteFile(url_path, url_contents_.c_str(), url_contents_.size());
- line.AppendSwitchPath(switches::kVisitURLs, url_path);
-
- // Set up Capture- or Replay-specific commandline switches.
- AddSwitches(&line);
-
- base::FilePath error_file_path = url_path.DirName().
- Append(url_path.BaseName().value() +
- base::FilePath::StringType(kURLErrorsSuffix));
-
- LOG(ERROR) << "Test browser commandline: " << line.GetCommandLineString() <<
- " will be repeated " << repeat_count_ << " times....";
-
- // Run the test browser (or a mockup, depending on |process_strategy_|.
- while (repeat_count_-- && errors_.empty() &&
- !base::PathExists(error_file_path))
- process_strategy_->RunProcess(line, &errors_);
-
- // Read URL errors file if there is one, and save errors in |errors_|.
- // Odd extension handling needed because temp files have lots of "."s in
- // their names, and we need to cleanly add kURLErrorsSuffix as a final
- // extension.
- if (errors_.empty() && base::PathExists(error_file_path)) {
- std::string error_content;
- file_util::ReadFileToString(error_file_path, &error_content);
-
- base::SplitString(error_content, '\n', &errors_);
- }
-
- // Do any special post-test-browser file reading (e.g. stats report))
- // while we're on the BlockingPool thread.
- ReadReplyFiles();
-
- // Back to UI thread to finish up the JS call.
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&RunPageCyclerFunction::Finish, this));
-}
-
-const ProcessStrategy &RunPageCyclerFunction::GetProcessStrategy() {
- return *process_strategy_;
-}
-
-// RecordCaptureURLsFunction ------------------------------------------------
-
-RecordCaptureURLsFunction::RecordCaptureURLsFunction()
- : RunPageCyclerFunction(new ProductionProcessStrategy()) {}
-
-RecordCaptureURLsFunction::RecordCaptureURLsFunction(ProcessStrategy* strategy)
- : RunPageCyclerFunction(strategy) {}
-
-// Fetch data for possible optional switch for an extension to load.
-bool RecordCaptureURLsFunction::ParseJSParameters() {
- scoped_ptr<record::CaptureURLs::Params> params(
- record::CaptureURLs::Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params.get());
-
- url_contents_ = JoinString(params->urls, '\n');
- // TODO(cstaley): Can't just use captureName -- gotta stick it in a temp dir.
- // TODO(cstaley): Ensure that capture name is suitable as directory name.
- user_data_dir_ = base::FilePath::FromUTF8Unsafe(params->capture_name);
-
- return true;
-}
-
-// RecordCaptureURLsFunction adds "record-mode" to sub-browser call, and returns
-// just the (possibly empty) error list.
-void RecordCaptureURLsFunction::AddSwitches(CommandLine* line) {
- if (!line->HasSwitch(switches::kRecordMode))
- line->AppendSwitch(switches::kRecordMode);
-}
-
-void RecordCaptureURLsFunction::Finish() {
- results_ = record::CaptureURLs::Results::Create(errors_);
- SendResponse(true);
-}
-
-// RecordReplayURLsFunction ------------------------------------------------
-
-RecordReplayURLsFunction::RecordReplayURLsFunction()
- : RunPageCyclerFunction(new ProductionProcessStrategy()),
- run_time_ms_(0.0) {
-}
-
-RecordReplayURLsFunction::RecordReplayURLsFunction(ProcessStrategy* strategy)
- : RunPageCyclerFunction(strategy), run_time_ms_(0.0) {
-}
-
-RecordReplayURLsFunction::~RecordReplayURLsFunction() {}
-
-// Fetch data for possible optional switches for a repeat count and an
-// extension to load.
-bool RecordReplayURLsFunction::ParseJSParameters() {
- scoped_ptr<record::ReplayURLs::Params> params(
- record::ReplayURLs::Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params.get());
-
-
- // TODO(cstaley): Must build full temp dir from capture_name
- user_data_dir_ = base::FilePath::FromUTF8Unsafe(params->capture_name);
-
- // TODO(cstaley): Get this from user data dir ultimately
- url_contents_ = "http://www.google.com\nhttp://www.amazon.com";
-
- repeat_count_ = params->repeat_count;
-
- if (params->details.get()) {
- if (params->details->extension_path.get())
- extension_path_ =
- base::FilePath::FromUTF8Unsafe(*params->details->extension_path);
- }
-
- return true;
-}
-
-// Add special switches, if indicated, for repeat count and extension to load,
-// plus temp file into which to place stats. (Can't do this in
-// ParseJSParameters because file creation can't go on the UI thread.)
-// Plus, initialize time to create run time statistic.
-void RecordReplayURLsFunction::AddSwitches(CommandLine* line) {
- file_util::CreateTemporaryFile(&stats_file_path_);
-
- if (!extension_path_.empty())
- line->AppendSwitchPath(switches::kLoadExtension, extension_path_);
- line->AppendSwitch(switches::kPlaybackMode);
- line->AppendSwitchPath(switches::kRecordStats, stats_file_path_);
-
- timer_ = base::Time::NowFromSystemTime();
-}
-
-// Read stats file, and get run time.
-void RecordReplayURLsFunction::ReadReplyFiles() {
- file_util::ReadFileToString(stats_file_path_, &stats_);
-
- run_time_ms_ = (base::Time::NowFromSystemTime() - timer_).InMillisecondsF();
-}
-
-void RecordReplayURLsFunction::Finish() {
- record::ReplayURLsResult result;
-
- result.run_time = run_time_ms_;
- result.stats = stats_;
- result.errors = errors_;
-
- results_ = record::ReplayURLs::Results::Create(result);
- SendResponse(true);
-}
-
-} // namespace extensions
diff --git a/chrome/browser/extensions/api/record/record_api.h b/chrome/browser/extensions/api/record/record_api.h
deleted file mode 100644
index d0ea960..0000000
--- a/chrome/browser/extensions/api/record/record_api.h
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_EXTENSIONS_API_RECORD_RECORD_API_H_
-#define CHROME_BROWSER_EXTENSIONS_API_RECORD_RECORD_API_H_
-
-#include "base/command_line.h"
-#include "base/files/file_path.h"
-#include "base/time/time.h"
-#include "chrome/browser/extensions/extension_function.h"
-
-namespace {
-
-const base::FilePath::CharType kURLErrorsSuffix[] =
- FILE_PATH_LITERAL(".errors");
-const char kErrorsKey[] = "errors";
-const char kStatsKey[] = "stats";
-
-};
-
-namespace extensions {
-
-// ProcessStrategy abstracts the API's starting and waiting on a test
-// browser instance. This lets us browser-test the API without actually
-// firing up a sub browser instance.
-class ProcessStrategy {
- public:
- // Needed to void build warnings
- virtual ~ProcessStrategy();
-
- // Used only in test version to pump the blocking pool queue,
- // which doesn't otherwise happen during test.
- virtual void PumpBlockingPool() {}
-
- // Start up process with given commandline. Real version does just
- // that; test version mocks it up, generating errors or good results,
- // as configured. If there are any problems running the process itself,
- // as opposed to errors in the cycler URL list, etc, report these via
- // |errors|
- virtual void RunProcess(const CommandLine& line,
- std::vector<std::string> *errors) = 0;
-};
-
-// Production (default) version of ProcessStrategy. See ProcessStrategy
-// comments for more info. This subclass actually starts a sub browser
-// instance.
-class ProductionProcessStrategy : public ProcessStrategy {
- public:
- virtual void RunProcess(const CommandLine& line,
- std::vector<std::string> *errors) OVERRIDE;
-};
-
-// Both page cycler calls (capture and replay) have a great deal in common,
-// including the need to build and write a url list file, set the user
-// data dir, start a sub-instance of Chrome, and parse a resultant error
-// file. This base class encapslates those common elements.
-class RunPageCyclerFunction : public AsyncExtensionFunction {
- public:
- explicit RunPageCyclerFunction(ProcessStrategy* strategy);
-
- // Make a CommandLine copy of |original|, removing all switches in
- // |to_remove|.
- static CommandLine RemoveSwitches(const CommandLine& original,
- const std::vector<std::string>& to_remove);
-
- // Return ProcessStrategy, to allow for test versions.
- virtual const ProcessStrategy &GetProcessStrategy();
-
- protected:
- virtual ~RunPageCyclerFunction();
-
- // Gather common page cycler parameters and store them, then do blocking
- // thread invocation of RunTestBrowser.
- virtual bool RunImpl() OVERRIDE;
-
- // Parse the JS parameters, and store them as member data.
- virtual bool ParseJSParameters() = 0;
-
- // Do a vanilla test browser run, bracketing it immediately before and
- // after with a call of AddSwitches to add special commandline options
- // for Capture or Replay, and ReadReplyFiles to do any special post-run
- // data collection. Gather any error results into |errors_| and then do a
- // BrowserThread call of Finish to return JS values.
- virtual void RunTestBrowser();
- virtual void AddSwitches(CommandLine* command_line) {}
-
- // The test browser communicates URL errors, performance statistics, and
- // possibly other data by posting them to text files. ReadReplyFiles
- // collects these data for return to the JS side caller.
- virtual void ReadReplyFiles() {}
-
- // Return the values gathered in RunTestBrowser. No common code here; all
- // logic is in subclasses.
- virtual void Finish() {}
-
- base::FilePath user_data_dir_;
- std::string url_contents_;
- int repeat_count_;
- std::vector<std::string> errors_;
-
- // Base CommandLine on which to build the test browser CommandLine
- CommandLine base_command_line_;
-
- // ProcessStrategy to use for this run.
- scoped_ptr<ProcessStrategy> process_strategy_;
-};
-
-class RecordCaptureURLsFunction : public RunPageCyclerFunction {
- public:
- DECLARE_EXTENSION_FUNCTION("experimental.record.captureURLs",
- EXPERIMENTAL_RECORD_CAPTUREURLS)
-
- RecordCaptureURLsFunction();
- explicit RecordCaptureURLsFunction(ProcessStrategy* strategy);
-
- private:
- virtual ~RecordCaptureURLsFunction() {}
-
- // Read the ReplayDetails parameter if it exists.
- virtual bool ParseJSParameters() OVERRIDE;
-
- // Add record-mode.
- virtual void AddSwitches(CommandLine* command_line) OVERRIDE;
-
- // Return error list.
- virtual void Finish() OVERRIDE;
-};
-
-class RecordReplayURLsFunction : public RunPageCyclerFunction {
- public:
- DECLARE_EXTENSION_FUNCTION("experimental.record.replayURLs",
- EXPERIMENTAL_RECORD_REPLAYURLS)
-
- RecordReplayURLsFunction();
- explicit RecordReplayURLsFunction(ProcessStrategy* strategy);
-
- private:
- virtual ~RecordReplayURLsFunction();
-
- // Read the ReplayDetails parameter if it exists.
- virtual bool ParseJSParameters() OVERRIDE;
-
- // Add visit-urls-count and load-extension.
- virtual void AddSwitches(CommandLine* command_line) OVERRIDE;
-
- // Read stats file.
- virtual void ReadReplyFiles() OVERRIDE;
-
- // Return error list, statistical results, and runtime.
- virtual void Finish() OVERRIDE;
-
- // These data are additional information added to the sub-browser
- // commandline or used to repeatedly run the sub-browser.
- base::FilePath extension_path_;
- base::FilePath stats_file_path_;
-
- // This time datum marks the start and end of the sub-browser run.
- base::Time timer_;
-
- // These two data are additional information returned to caller.
- double run_time_ms_;
- std::string stats_;
-};
-
-} // namespace extensions
-
-#endif // CHROME_BROWSER_EXTENSIONS_API_RECORD_RECORD_API_H_
diff --git a/chrome/browser/extensions/api/record/record_api_test.cc b/chrome/browser/extensions/api/record/record_api_test.cc
deleted file mode 100644
index 40813a21..0000000
--- a/chrome/browser/extensions/api/record/record_api_test.cc
+++ /dev/null
@@ -1,353 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/extensions/api/record/record_api.h"
-
-#include <string>
-
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/path_service.h"
-#include "base/strings/string_split.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/threading/sequenced_worker_pool.h"
-#include "base/values.h"
-#include "chrome/browser/extensions/extension_function_test_utils.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_window.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/api/experimental_record.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/ui_test_utils.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/common/content_switches.h"
-
-namespace utils = extension_function_test_utils;
-
-namespace extensions {
-
-namespace {
-
-// Dummy content for mock stats file.
-const std::string kTestStatistics = "Sample Stat 1\nSample Stat 2\n";
-
-// Standard capture parameters, with a mix of good and bad URLs, and
-// a hole for filling in the user data dir.
-
-// Restore these on the next CL of the new page cycler, when the C++
-// side's implementation is de-hacked.
-//const char kCaptureArgs1[] =
-// "[\"%s\", [\"URL 1\", \"URL 2(bad)\", \"URL 3\", \"URL 4(bad)\"]]";
-
-const char kCaptureArgs1[] =
- "[\"%s\", [\"http://www.google.com\", \"http://www.amazon.com\"]]";
-
-// Standard playback parameters, with the same mix of good and bad URLs
-// as the capture parameters, a hole for filling in the user data dir, and
-// a mocked-up extension path and repeat count (which are used only to
-// verify that they made it into the CommandLine, since extension loading
-// and repeat-counting are hard to emulate in the test ProcessStrategy.
-const char kPlaybackArgs1[] =
- "[\"%s\", 2, {\"extensionPath\": \"MockExtension\"}]";
-
-// Use this as the value of base::FilePath switches (e.g. user-data-dir) that
-// should be replaced by the record methods.
-const base::FilePath::CharType kDummyDirName[] = FILE_PATH_LITERAL("ReplaceMe");
-
-// Use this as the filename for a mock "cache" file in the user-data-dir.
-const base::FilePath::CharType kMockCacheFile[] =
- FILE_PATH_LITERAL("MockCache");
-
-}
-
-class TestProcessStrategy : public ProcessStrategy {
- public:
- explicit TestProcessStrategy(std::vector<base::FilePath>* temp_files)
- : command_line_(CommandLine::NO_PROGRAM), temp_files_(temp_files) {}
-
- virtual ~TestProcessStrategy() {}
-
- // Pump the blocking pool queue, since this is needed during test.
- virtual void PumpBlockingPool() OVERRIDE {
- content::BrowserThread::GetBlockingPool()->FlushForTesting();
- }
-
- // Act somewhat like a real test browser instance. In particular:
- // 1. If visit-urls, then
- // a. If record-mode, then put a copy of the URL list into the user data
- // directory in a mocked up cache file
- // b. If playback-mode, then check for existence of that URL list copy
- // in the cache
- // c. Scan list of URLS, noting in |urls_visited_| all those
- // visited. If there are any "bad" URLS, don't visit these, but
- // create a ".errors" file listing them.
- // 2. If record-stats, then create a mock stats file.
- virtual void RunProcess(const CommandLine& command_line,
- std::vector<std::string>* errors) OVERRIDE {
- command_line_ = command_line;
- visited_urls_.clear();
-
- if (command_line.HasSwitch(switches::kVisitURLs)) {
- base::FilePath url_path =
- command_line.GetSwitchValuePath(switches::kVisitURLs);
-
- temp_files_->push_back(url_path);
- if (command_line.HasSwitch(switches::kRecordMode) ||
- command_line.HasSwitch(switches::kPlaybackMode)) {
- base::FilePath url_path_copy = command_line.GetSwitchValuePath(
- switches::kUserDataDir).Append(
- base::FilePath(base::FilePath::StringType(kMockCacheFile)));
-
- if (command_line.HasSwitch(switches::kRecordMode)) {
- base::CopyFile(url_path, url_path_copy);
- } else {
- if (!base::ContentsEqual(url_path, url_path_copy)) {
- std::string contents1, contents2;
- file_util::ReadFileToString(url_path, &contents1);
- file_util::ReadFileToString(url_path_copy, &contents2);
- LOG(ERROR) << "FILE MISMATCH" << contents1 << " VS " << contents2;
- }
- EXPECT_TRUE(base::ContentsEqual(url_path, url_path_copy));
- }
- }
-
- std::string urls;
- file_util::ReadFileToString(url_path, &urls);
-
- std::vector<std::string> url_vector, bad_urls;
- base::SplitString(urls, '\n', &url_vector);
- for (std::vector<std::string>::iterator itr = url_vector.begin();
- itr != url_vector.end(); ++itr) {
- if (itr->find_first_of("bad") != std::string::npos)
- bad_urls.push_back(*itr);
- else
- visited_urls_.push_back(*itr);
- }
-
- if (!bad_urls.empty()) {
- base::FilePath url_errors_path = url_path.DirName()
- .Append(url_path.BaseName().value() +
- base::FilePath::StringType(kURLErrorsSuffix));
- std::string error_content = JoinString(bad_urls, '\n');
- temp_files_->push_back(url_errors_path);
- file_util::WriteFile(url_errors_path, error_content.c_str(),
- error_content.size());
- }
- }
-
- if (command_line.HasSwitch(switches::kRecordStats)) {
- base::FilePath record_stats_path(command_line.GetSwitchValuePath(
- switches::kRecordStats));
- temp_files_->push_back(record_stats_path);
- file_util::WriteFile(record_stats_path, kTestStatistics.c_str(),
- kTestStatistics.size());
- }
- }
-
- const CommandLine& GetCommandLine() const {
- return command_line_;
- }
-
- const std::vector<std::string>& GetVisitedURLs() const {
- return visited_urls_;
- }
-
- private:
- CommandLine command_line_;
- std::vector<std::string> visited_urls_;
- std::vector<base::FilePath>* temp_files_;
-};
-
-class RecordApiTest : public InProcessBrowserTest {
- public:
- RecordApiTest() {}
- virtual ~RecordApiTest() {}
-
- // Override to scope known temp directories outside the scope of the running
- // browser test.
- virtual void SetUp() OVERRIDE {
- InProcessBrowserTest::SetUp();
- if (!scoped_temp_user_data_dir_.Set(base::FilePath(kDummyDirName)))
- NOTREACHED();
- }
-
- // Override to delete temp directories.
- virtual void TearDown() OVERRIDE {
- if (!scoped_temp_user_data_dir_.Delete())
- NOTREACHED();
- InProcessBrowserTest::TearDown();
- }
-
- // Override to delete temporary files created during execution.
- virtual void CleanUpOnMainThread() OVERRIDE {
- InProcessBrowserTest::CleanUpOnMainThread();
- for (std::vector<base::FilePath>::const_iterator it = temp_files_.begin();
- it != temp_files_.end(); ++it) {
- if (!base::DeleteFile(*it, false))
- NOTREACHED();
- }
- }
-
- // Override SetUpCommandline to specify a dummy user_data_dir, which
- // should be replaced. Clear record-mode, playback-mode, visit-urls,
- // record-stats, and load-extension.
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- std::vector<std::string> remove_switches;
-
- remove_switches.push_back(switches::kUserDataDir);
- remove_switches.push_back(switches::kVisitURLs);
- remove_switches.push_back(switches::kPlaybackMode);
- remove_switches.push_back(switches::kRecordStats);
- remove_switches.push_back(switches::kLoadExtension);
- *command_line = RunPageCyclerFunction::RemoveSwitches(*command_line,
- remove_switches);
-
- command_line->AppendSwitchPath(switches::kUserDataDir,
- base::FilePath(kDummyDirName));
- // Adding a dummy load-extension switch is rather complex since the
- // preent design of InProcessBrowserTest requires a *real* extension
- // for the flag, even if we're just testing its replacement. Opted
- // to omit this for the sake of simplicity.
- }
-
- // Run a capture, using standard URL test list and the specified
- // user data dir. Return via |out_list| the list of error URLs,
- // if any, resulting from the capture. And return directly the
- // RecordCaptureURLsFunction that was used, so that its state may be
- // queried.
- scoped_refptr<RecordCaptureURLsFunction> RunCapture(
- const base::FilePath& user_data_dir,
- scoped_ptr<base::ListValue>* out_list) {
-
- scoped_refptr<RecordCaptureURLsFunction> capture_function(
- new RecordCaptureURLsFunction(new TestProcessStrategy(&temp_files_)));
-
- std::string escaped_user_data_dir;
- ReplaceChars(user_data_dir.AsUTF8Unsafe(), "\\", "\\\\",
- &escaped_user_data_dir);
-
- out_list->reset(utils::ToList(
- utils::RunFunctionAndReturnSingleResult(capture_function.get(),
- base::StringPrintf(kCaptureArgs1, escaped_user_data_dir.c_str()),
- browser())));
-
- return capture_function;
- }
-
- // Verify that the URL list of good and bad URLs was properly handled.
- // Needed by several tests.
- bool VerifyURLHandling(const base::ListValue* result,
- const TestProcessStrategy& strategy) {
-
- // Check that the two bad URLs are returned.
- StringValue badURL2("URL 2(bad)"), badURL4("URL 4(bad)");
-
- /* TODO(CAS) Need to rework this once the new record API is implemented.
- const base::Value* string_value = NULL;
- EXPECT_TRUE(result->GetSize() == 2);
- result->Get(0, &string_value);
- EXPECT_TRUE(base::Value::Equals(string_value, &badURL2));
- result->Get(1, &string_value);
- EXPECT_TRUE(base::Value::Equals(string_value, &badURL4));
-
- // Check that both good URLs were visited.
- std::string goodURL1("URL 1"), goodURL3("URL 3");
- EXPECT_TRUE(strategy.GetVisitedURLs()[0].compare(goodURL1) == 0
- && strategy.GetVisitedURLs()[1].compare(goodURL3) == 0);
- */
-
- return true;
- }
-
- protected:
- std::vector<base::FilePath> temp_files_;
-
- private:
- base::ScopedTempDir scoped_temp_user_data_dir_;
-
- DISALLOW_COPY_AND_ASSIGN(RecordApiTest);
-};
-
-
-IN_PROC_BROWSER_TEST_F(RecordApiTest, DISABLED_CheckCapture) {
- base::ScopedTempDir user_data_dir;
- scoped_ptr<base::ListValue> result;
-
- EXPECT_TRUE(user_data_dir.CreateUniqueTempDir());
- scoped_refptr<RecordCaptureURLsFunction> capture_URLs_function =
- RunCapture(user_data_dir.path(), &result);
-
- // Check that user-data-dir switch has been properly overridden.
- const TestProcessStrategy &strategy =
- static_cast<const TestProcessStrategy &>(
- capture_URLs_function->GetProcessStrategy());
- const CommandLine& command_line = strategy.GetCommandLine();
-
- EXPECT_TRUE(command_line.HasSwitch(switches::kUserDataDir));
- EXPECT_TRUE(command_line.GetSwitchValuePath(switches::kUserDataDir) !=
- base::FilePath(kDummyDirName));
-
- EXPECT_TRUE(VerifyURLHandling(result.get(), strategy));
-}
-
-#if defined(ADDRESS_SANITIZER)
-// Times out under ASan, see http://crbug.com/130267.
-#define MAYBE_CheckPlayback DISABLED_CheckPlayback
-#else
-// Flaky on all platforms, see http://crbug.com/167143
-#define MAYBE_CheckPlayback DISABLED_CheckPlayback
-#endif
-IN_PROC_BROWSER_TEST_F(RecordApiTest, MAYBE_CheckPlayback) {
- base::ScopedTempDir user_data_dir;
-
- EXPECT_TRUE(user_data_dir.CreateUniqueTempDir());
-
- // Assume this RunCapture operates w/o error, since it's tested
- // elsewhere.
- scoped_ptr<base::ListValue> capture_result;
- RunCapture(user_data_dir.path(), &capture_result);
-
- std::string escaped_user_data_dir;
- ReplaceChars(user_data_dir.path().AsUTF8Unsafe(), "\\", "\\\\",
- &escaped_user_data_dir);
-
- scoped_refptr<RecordReplayURLsFunction> playback_function(
- new RecordReplayURLsFunction(
- new TestProcessStrategy(&temp_files_)));
- scoped_ptr<base::DictionaryValue> result(
- utils::ToDictionary(utils::RunFunctionAndReturnSingleResult(
- playback_function.get(),
- base::StringPrintf(kPlaybackArgs1, escaped_user_data_dir.c_str()),
- browser())));
-
- // Check that command line user-data-dir was overridden. (That
- // it was *consistently* overridden in both capture and replay
- // is verified elsewhere.
- const TestProcessStrategy &strategy =
- static_cast<const TestProcessStrategy &>(
- playback_function->GetProcessStrategy());
- const CommandLine& command_line = strategy.GetCommandLine();
-
- EXPECT_TRUE(command_line.HasSwitch(switches::kUserDataDir));
- EXPECT_TRUE(command_line.GetSwitchValuePath(switches::kUserDataDir) !=
- base::FilePath(kDummyDirName));
-
- // Check that command line load-extension was overridden.
- EXPECT_TRUE(command_line.HasSwitch(switches::kLoadExtension) &&
- command_line.GetSwitchValuePath(switches::kLoadExtension)
- != base::FilePath(kDummyDirName));
-
- // Check for return value with proper stats.
- EXPECT_EQ(kTestStatistics, utils::GetString(result.get(), kStatsKey));
-
- base::ListValue* errors = NULL;
- EXPECT_TRUE(result->GetList(kErrorsKey, &errors));
- EXPECT_TRUE(VerifyURLHandling(errors, strategy));
-}
-
-} // namespace extensions
diff --git a/chrome/browser/extensions/extension_function_histogram_value.h b/chrome/browser/extensions/extension_function_histogram_value.h
index 2fe8af1e..1fb745d 100644
--- a/chrome/browser/extensions/extension_function_histogram_value.h
+++ b/chrome/browser/extensions/extension_function_histogram_value.h
@@ -240,7 +240,7 @@
BOOKMARKS_GETTREE,
FILEBROWSERPRIVATE_SELECTFILES,
RUNTIME_GETBACKGROUNDPAGE,
- EXPERIMENTAL_RECORD_REPLAYURLS,
+ DELETED_EXPERIMENTAL_RECORD_REPLAYURLS,
WEBSTOREPRIVATE_COMPLETEINSTALL,
DELETED_EXPERIMENTAL_SPEECHINPUT_START,
COOKIES_GETALL,
@@ -410,7 +410,7 @@
CONTEXTMENUS_CREATE,
MEDIAPLAYERPRIVATE_GETPLAYLIST,
DOWNLOADS_ERASE,
- EXPERIMENTAL_RECORD_CAPTUREURLS,
+ DELETED_EXPERIMENTAL_RECORD_CAPTUREURLS,
TTS_ISSPEAKING,
BOOKMARKS_REMOVETREE,
FILEBROWSERPRIVATE_SEARCHDRIVE,