summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorcmasone@chromium.org <cmasone@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-20 02:27:19 +0000
committercmasone@chromium.org <cmasone@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-20 02:27:19 +0000
commita2760145a30d0bfaf359365b267bc04479140849 (patch)
treedfa493b7d2b65a4a0fde589d4934d2c0eeeb5e6e /chrome
parentbd79e3ec08596dd3cb5656811de9db1b177a2aef (diff)
downloadchromium_src-a2760145a30d0bfaf359365b267bc04479140849.zip
chromium_src-a2760145a30d0bfaf359365b267bc04479140849.tar.gz
chromium_src-a2760145a30d0bfaf359365b267bc04479140849.tar.bz2
[Chrome OS] Remove obsolete PipeReader, ExternalCookieFetcher classes
One of the PipeReaderTest tests is flaky. That code is obsolete anyway, so just remove all of it. BUG=63228 TEST=chrome, test targets compile without this code Review URL: http://codereview.chromium.org/5203004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66864 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/external_cookie_handler.cc65
-rw-r--r--chrome/browser/chromeos/external_cookie_handler.h49
-rw-r--r--chrome/browser/chromeos/external_cookie_handler_unittest.cc131
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc1
-rw-r--r--chrome/browser/chromeos/pipe_reader.cc36
-rw-r--r--chrome/browser/chromeos/pipe_reader.h50
-rw-r--r--chrome/browser/chromeos/pipe_reader_unittest.cc119
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/chrome_tests.gypi2
9 files changed, 0 insertions, 457 deletions
diff --git a/chrome/browser/chromeos/external_cookie_handler.cc b/chrome/browser/chromeos/external_cookie_handler.cc
deleted file mode 100644
index 3af6b04..0000000
--- a/chrome/browser/chromeos/external_cookie_handler.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2009 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/chromeos/external_cookie_handler.h"
-
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "chrome/browser/chromeos/pipe_reader.h"
-#include "chrome/browser/profile.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/net/url_request_context_getter.h"
-#include "googleurl/src/gurl.h"
-#include "net/base/cookie_store.h"
-#include "net/url_request/url_request_context.h"
-
-namespace chromeos {
-
-// static
-const char ExternalCookieHandler::kGoogleAccountsUrl[] =
- "https://www.google.com/a/google.com/acs";
-
-const int kChunkSize = 256;
-
-// Reads up to a newline, or the end of the data, in increments of |chunk|
-std::string ExternalCookieHandler::ReadLine(int chunk) {
- std::string cookie_line = reader_->Read(chunk);
-
- // As long as it's not an empty line...
- if (!cookie_line.empty()) {
- // and there's no newline at the end...
- while ('\n' != cookie_line[cookie_line.length() - 1]) {
- // try to pull more data...
- std::string piece = reader_->Read(chunk);
- if (piece.empty()) // only stop if there's none left.
- break;
- else
- cookie_line.append(piece); // otherwise, append and keep going.
- }
- }
-
- return cookie_line;
-}
-
-bool ExternalCookieHandler::HandleCookies(net::CookieStore *cookie_store) {
- DCHECK(cookie_store);
- if (NULL != reader_.get()) {
- GURL url(ExternalCookieHandler::kGoogleAccountsUrl);
- net::CookieOptions options;
- options.set_include_httponly();
-
- // Each line we get is a cookie. Grab up to a newline, then put
- // it in to the cookie jar.
- std::string cookie_line = ReadLine(kChunkSize);
- while (!cookie_line.empty()) {
- if (!cookie_store->SetCookieWithOptions(url, cookie_line, options))
- return false;
- cookie_line = ReadLine(kChunkSize);
- }
- return true;
- }
- return false;
-}
-
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/external_cookie_handler.h b/chrome/browser/chromeos/external_cookie_handler.h
deleted file mode 100644
index b422ace..0000000
--- a/chrome/browser/chromeos/external_cookie_handler.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2009 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_CHROMEOS_EXTERNAL_COOKIE_HANDLER_H_
-#define CHROME_BROWSER_CHROMEOS_EXTERNAL_COOKIE_HANDLER_H_
-#pragma once
-
-#include <string>
-
-#include "base/scoped_ptr.h"
-#include "chrome/browser/chromeos/pipe_reader.h"
-
-// Single sign on cookies for Google can be passed in over a
-// pipe. If they've been sent, this reads them and adds them to the
-// cookie store as session cookies.
-
-class CommandLine;
-class Profile;
-namespace net {
-class CookieStore;
-}
-
-namespace chromeos {
-
-class ExternalCookieHandler {
- public:
- // Takes ownsership of |reader|.
- explicit ExternalCookieHandler(PipeReader *reader) : reader_(reader) {}
- virtual ~ExternalCookieHandler() {}
-
- // Given a pipe to read cookies from, reads and adds them to |cookie_store|.
- virtual bool HandleCookies(net::CookieStore *cookie_store);
-
- // The url with which we associate the read-in cookies.
- static const char kGoogleAccountsUrl[];
-
- private:
- // Reads up to a newline, or the end of the data, in increments of |chunk|.
- std::string ReadLine(int chunk);
-
- scoped_ptr<PipeReader> reader_;
-
- DISALLOW_COPY_AND_ASSIGN(ExternalCookieHandler);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_EXTERNAL_COOKIE_HANDLER_H_
diff --git a/chrome/browser/chromeos/external_cookie_handler_unittest.cc b/chrome/browser/chromeos/external_cookie_handler_unittest.cc
deleted file mode 100644
index c1ac783..0000000
--- a/chrome/browser/chromeos/external_cookie_handler_unittest.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright (c) 2010 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/chromeos/external_cookie_handler.h"
-
-#include <set>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/time.h"
-#include "googleurl/src/gurl.h"
-#include "net/base/cookie_options.h"
-#include "net/base/cookie_store.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-
-typedef testing::Test ExternalCookieHandlerTest;
-
-static const std::string cookie1 = "coookie1\n";
-static const std::string cookie2 = "coookie2\n";
-static const std::string cookie3 = "coookie3";
-
-class MockCookieStore : public net::CookieStore {
- public:
- MockCookieStore() : expected_url_(ExternalCookieHandler::kGoogleAccountsUrl) {
- cookies_.insert(cookie1);
- cookies_.insert(cookie2);
- cookies_.insert(cookie3);
- }
- virtual ~MockCookieStore() {}
-
- virtual bool SetCookieWithOptions(const GURL& url,
- const std::string& cookie_line,
- const net::CookieOptions& options) {
- EXPECT_FALSE(options.exclude_httponly());
- EXPECT_EQ(expected_url_, url);
- std::set<std::string>::iterator it;
- it = cookies_.find(cookie_line);
- bool has_cookie = cookies_.end() != it;
- if (has_cookie)
- cookies_.erase(it);
- return has_cookie;
- }
-
- virtual std::string GetCookiesWithOptions(const GURL& url,
- const net::CookieOptions& options) {
- EXPECT_TRUE(false);
- return std::string();
- }
-
- virtual void DeleteCookie(const GURL& url,
- const std::string& cookie_name) {
- EXPECT_TRUE(false);
- }
-
- virtual net::CookieMonster* GetCookieMonster() { return NULL; }
-
- private:
- std::set<std::string> cookies_;
- const GURL expected_url_;
-
- DISALLOW_COPY_AND_ASSIGN(MockCookieStore);
-};
-
-TEST_F(ExternalCookieHandlerTest, MockCookieStoreSanityTest) {
- GURL url(ExternalCookieHandler::kGoogleAccountsUrl);
- // Need to use a scoped_refptr here because net::CookieStore extends
- // base::RefCountedThreadSafe<> in base/ref_counted.h.
- scoped_refptr<MockCookieStore> cookie_store(new MockCookieStore);
- net::CookieOptions options;
- options.set_include_httponly();
- EXPECT_TRUE(cookie_store->SetCookieWithOptions(url, cookie1, options));
- EXPECT_TRUE(cookie_store->SetCookieWithOptions(url, cookie2, options));
- EXPECT_TRUE(cookie_store->SetCookieWithOptions(url, cookie3, options));
- EXPECT_FALSE(cookie_store->SetCookieWithOptions(url, cookie1, options));
- EXPECT_FALSE(cookie_store->SetCookieWithOptions(url, cookie2, options));
- EXPECT_FALSE(cookie_store->SetCookieWithOptions(url, cookie3, options));
-}
-
-class MockReader : public PipeReader {
- public:
- explicit MockReader(const std::vector<std::string>& cookies)
- : data_(cookies) {
- }
-
- std::string Read(const uint32 bytes_to_read) {
- std::string to_return;
- if (!data_.empty()) {
- to_return = data_.back();
- data_.pop_back();
- }
- return to_return;
- }
- private:
- std::vector<std::string> data_;
-};
-
-TEST_F(ExternalCookieHandlerTest, SuccessfulReadTest) {
- GURL url(ExternalCookieHandler::kGoogleAccountsUrl);
-
- scoped_refptr<MockCookieStore> cookie_store(new MockCookieStore);
-
- std::vector<std::string> cookies;
- cookies.push_back(cookie3);
- cookies.push_back(cookie2);
- cookies.push_back(cookie1);
- MockReader *reader = new MockReader(cookies);
-
- ExternalCookieHandler handler(reader); // takes ownership.
- EXPECT_TRUE(handler.HandleCookies(cookie_store.get()));
-}
-
-TEST_F(ExternalCookieHandlerTest, SuccessfulSlowReadTest) {
- GURL url(ExternalCookieHandler::kGoogleAccountsUrl);
-
- scoped_refptr<MockCookieStore> cookie_store(new MockCookieStore);
-
- std::vector<std::string> cookies;
- cookies.push_back(cookie3);
- cookies.push_back(cookie2.substr(2));
- cookies.push_back(cookie2.substr(0, 2));
- cookies.push_back(cookie1);
- MockReader *reader = new MockReader(cookies);
-
- ExternalCookieHandler handler(reader); // takes ownership.
- EXPECT_TRUE(handler.HandleCookies(cookie_store.get()));
-}
-
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index c8ad2d2..80b7d20 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/cros/login_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
-#include "chrome/browser/chromeos/external_cookie_handler.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/login/cookie_fetcher.h"
#include "chrome/browser/chromeos/login/google_authenticator.h"
diff --git a/chrome/browser/chromeos/pipe_reader.cc b/chrome/browser/chromeos/pipe_reader.cc
deleted file mode 100644
index 8664e35..0000000
--- a/chrome/browser/chromeos/pipe_reader.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2010 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/chromeos/pipe_reader.h"
-
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "base/file_path.h"
-#include "base/scoped_ptr.h"
-
-namespace chromeos {
-
-PipeReader::PipeReader(const FilePath& pipe_name)
- : pipe_(NULL),
- pipe_name_(pipe_name.value()) {
-}
-
-PipeReader::~PipeReader() {
- if (pipe_)
- fclose(pipe_);
-}
-
-std::string PipeReader::Read(const uint32 bytes_to_read) {
- scoped_array<char> buffer(new char[bytes_to_read]);
- if (pipe_ || (pipe_ = fopen(pipe_name_.c_str(), "r"))) {
- const char* to_return = fgets(buffer.get(), bytes_to_read, pipe_);
- if (to_return)
- return to_return; // auto-coerced to a std::string.
- }
- return std::string();
-}
-
-} // namespace chromeos
diff --git a/chrome/browser/chromeos/pipe_reader.h b/chrome/browser/chromeos/pipe_reader.h
deleted file mode 100644
index 821fe95..0000000
--- a/chrome/browser/chromeos/pipe_reader.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2010 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_CHROMEOS_PIPE_READER_H_
-#define CHROME_BROWSER_CHROMEOS_PIPE_READER_H_
-#pragma once
-
-#include <stdio.h>
-#include <unistd.h>
-
-#include <string>
-
-#include "base/basictypes.h"
-
-class FilePath;
-
-namespace chromeos {
-
-// Given a named pipe, this class reads data from it and returns it as a string.
-// Currently, we are sending login cookies from the Chrome OS login manager to
-// Chrome over a named Unix pipe. We want to replace this with DBus, but
-// would like to create a DBus wrapper library to use throughout Chrome OS
-// first. This stopgap lets us get the infrastructure for passing credentials
-// to Chrome in place, which will help clean up login jankiness, and also
-// refactor our code as we await the DBus stuff.
-// TODO(cmasone): get rid of this code and replace with DBus.
-
-class PipeReader {
- public:
- explicit PipeReader(const FilePath& pipe_name);
- virtual ~PipeReader();
-
- // Reads data from the pipe up until either a '\n' or |bytes_to_read| bytes.
- virtual std::string Read(const uint32 bytes_to_read);
-
- protected:
- // For testing.
- PipeReader() : pipe_(NULL) {}
-
- private:
- FILE *pipe_;
- std::string pipe_name_;
-
- DISALLOW_COPY_AND_ASSIGN(PipeReader);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_PIPE_READER_H_
diff --git a/chrome/browser/chromeos/pipe_reader_unittest.cc b/chrome/browser/chromeos/pipe_reader_unittest.cc
deleted file mode 100644
index 3cb55ee..0000000
--- a/chrome/browser/chromeos/pipe_reader_unittest.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (c) 2010 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/chromeos/pipe_reader.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include "base/file_path.h"
-#include "base/safe_strerror_posix.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-
-typedef testing::Test PipeReaderTest;
-
-TEST_F(PipeReaderTest, SuccessfulReadTest) {
- FilePath pipe_name("/tmp/MYFIFO");
- /* Create the FIFO if it does not exist */
- umask(0);
- mknod(pipe_name.value().c_str(), S_IFIFO|0666, 0);
- const char line[] = "foo";
-
- pid_t pID = fork();
- if (pID == 0) {
- int pipe = open(pipe_name.value().c_str(), O_WRONLY);
- EXPECT_NE(pipe, -1) << safe_strerror(errno);
- int num_bytes = write(pipe, line, strlen(line));
- EXPECT_NE(num_bytes, -1) << safe_strerror(errno);
- close(pipe);
- exit(1);
- } else {
- PipeReader reader(pipe_name);
- // asking for more should still just return the amount that was written.
- EXPECT_EQ(line, reader.Read(5 * strlen(line)));
- }
-}
-
-TEST_F(PipeReaderTest, SuccessfulMultiLineReadTest) {
- FilePath pipe_name("/tmp/TESTFIFO");
- /* Create the FIFO if it does not exist */
- umask(0);
- mknod(pipe_name.value().c_str(), S_IFIFO|0666, 0);
- const char foo[] = "foo";
- const char boo[] = "boo";
- std::string line(foo);
- line.append("\n");
- line.append(boo);
- line.append("\n");
-
- pid_t pID = fork();
- if (pID == 0) {
- int pipe = open(pipe_name.value().c_str(), O_WRONLY);
- EXPECT_NE(pipe, -1) << safe_strerror(errno);
- int num_bytes = write(pipe, line.c_str(), line.length());
- EXPECT_NE(num_bytes, -1) << safe_strerror(errno);
- close(pipe);
- exit(1);
- } else {
- PipeReader reader(pipe_name);
- // asking for more should still just return the amount that was written.
- std::string my_foo = reader.Read(5 * line.length());
- ASSERT_GT(my_foo.length(), 0U);
- EXPECT_EQ(my_foo[my_foo.length() - 1], '\n');
- my_foo.resize(my_foo.length() - 1);
- EXPECT_EQ(my_foo, foo);
-
- std::string my_boo = reader.Read(5 * line.length());
- ASSERT_GT(my_boo.length(), 0U);
- EXPECT_EQ(my_boo[my_boo.length() - 1], '\n');
- my_boo.resize(my_boo.length() - 1);
- EXPECT_EQ(my_boo, boo);
- }
-}
-
-// http://crbug.com/63228
-#if defined(OS_CHROMEOS)
-#define MAYBE_SuccessfulMultiLineReadNoEndingNewlineTest FLAKY_SuccessfulMultiLineReadNoEndingNewlineTest
-#else
-#define MAYBE_SuccessfulMultiLineReadNoEndingNewlineTest SuccessfulMultiLineReadNoEndingNewlineTest
-#endif
-
-TEST_F(PipeReaderTest, MAYBE_SuccessfulMultiLineReadNoEndingNewlineTest) {
- FilePath pipe_name("/tmp/TESTFIFO");
- /* Create the FIFO if it does not exist */
- umask(0);
- mknod(pipe_name.value().c_str(), S_IFIFO|0666, 0);
- const char foo[] = "foo";
- const char boo[] = "boo";
- std::string line(foo);
- line.append("\n");
- line.append(boo);
-
- pid_t pID = fork();
- if (pID == 0) {
- int pipe = open(pipe_name.value().c_str(), O_WRONLY);
- EXPECT_NE(pipe, -1) << safe_strerror(errno);
- int num_bytes = write(pipe, line.c_str(), line.length());
- EXPECT_NE(num_bytes, -1) << safe_strerror(errno);
- close(pipe);
- exit(1);
- } else {
- PipeReader reader(pipe_name);
- // asking for more should still just return the amount that was written.
- std::string my_foo = reader.Read(5 * line.length());
- ASSERT_GT(my_foo.length(), 0U);
- EXPECT_EQ(my_foo[my_foo.length() - 1], '\n');
- my_foo.resize(my_foo.length() - 1);
- EXPECT_EQ(my_foo, foo);
-
- std::string my_boo = reader.Read(5 * line.length());
- EXPECT_EQ(my_boo, boo);
- }
-}
-
-} // namespace chromeos
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 8cbfa84..7a547cd 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -482,8 +482,6 @@
'browser/chromeos/dom_ui/wrench_menu_ui.cc',
'browser/chromeos/dom_ui/wrench_menu_ui.h',
'browser/chromeos/drop_shadow_label.cc',
- 'browser/chromeos/external_cookie_handler.cc',
- 'browser/chromeos/external_cookie_handler.h',
'browser/chromeos/external_metrics.cc',
'browser/chromeos/external_metrics.h',
'browser/chromeos/external_protocol_dialog.cc',
@@ -700,8 +698,6 @@
'browser/chromeos/panels/panel_scroller_container.h',
'browser/chromeos/panels/panel_scroller_header.cc',
'browser/chromeos/panels/panel_scroller_header.h',
- 'browser/chromeos/pipe_reader.cc',
- 'browser/chromeos/pipe_reader.h',
'browser/chromeos/plugin_selection_policy.cc',
'browser/chromeos/plugin_selection_policy.h',
'browser/chromeos/preferences.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 9a1dd4c..5ddfcdc 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1050,7 +1050,6 @@
'browser/chrome_plugin_unittest.cc',
'browser/chromeos/customization_document_unittest.cc',
'browser/chromeos/dom_ui/language_options_handler_unittest.cc',
- 'browser/chromeos/external_cookie_handler_unittest.cc',
'browser/chromeos/external_metrics_unittest.cc',
'browser/chromeos/gview_request_interceptor_unittest.cc',
'browser/chromeos/input_method/input_method_util_unittest.cc',
@@ -1078,7 +1077,6 @@
'browser/chromeos/notifications/desktop_notifications_unittest.cc',
'browser/chromeos/offline/offline_load_page_unittest.cc',
'browser/chromeos/options/language_config_model_unittest.cc',
- 'browser/chromeos/pipe_reader_unittest.cc',
'browser/chromeos/plugin_selection_policy_unittest.cc',
'browser/chromeos/proxy_config_service_impl_unittest.cc',
'browser/chromeos/status/input_method_menu_unittest.cc',