summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-17 00:26:18 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-17 00:26:18 +0000
commit797c355020734dc32ffa57f54d032afa20f018c8 (patch)
tree8a3a745aea8a8b7bf81c049f387eaa6321bf9bbc /chrome
parentf6179ec31d0d530bd2ed66808bb24b601d60d453 (diff)
downloadchromium_src-797c355020734dc32ffa57f54d032afa20f018c8.zip
chromium_src-797c355020734dc32ffa57f54d032afa20f018c8.tar.gz
chromium_src-797c355020734dc32ffa57f54d032afa20f018c8.tar.bz2
Move a bunch of files from chrome\common to content\common.
TBR=avi Review URL: http://codereview.chromium.org/6677096 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78473 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/geolocation/geolocation_browsertest.cc2
-rw-r--r--chrome/browser/history/history_backend.h2
-rw-r--r--chrome/browser/history/text_database_manager.cc2
-rw-r--r--chrome/browser/history/text_database_manager.h2
-rw-r--r--chrome/chrome_common.gypi9
-rw-r--r--chrome/chrome_tests.gypi4
-rw-r--r--chrome/common/common_param_traits.cc2
-rw-r--r--chrome/common/common_param_traits_unittest.cc2
-rw-r--r--chrome/common/desktop_notifications/active_notification_tracker.cc84
-rw-r--r--chrome/common/desktop_notifications/active_notification_tracker.h58
-rw-r--r--chrome/common/desktop_notifications/active_notification_tracker_unittest.cc25
-rw-r--r--chrome/common/font_config_ipc_linux.cc110
-rw-r--r--chrome/common/font_config_ipc_linux.h40
-rw-r--r--chrome/common/geoposition.cc66
-rw-r--r--chrome/common/geoposition.h65
-rw-r--r--chrome/common/mru_cache.h253
-rw-r--r--chrome/common/mru_cache_unittest.cc253
-rw-r--r--chrome/common/render_messages.h2
-rw-r--r--chrome/common/unix_domain_socket_posix.cc146
-rw-r--r--chrome/common/unix_domain_socket_posix.h54
-rw-r--r--chrome/renderer/renderer_sandbox_support_linux.cc2
21 files changed, 10 insertions, 1173 deletions
diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc
index 01a43400..3e9d181 100644
--- a/chrome/browser/geolocation/geolocation_browsertest.cc
+++ b/chrome/browser/geolocation/geolocation_browsertest.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_paths.h"
-#include "chrome/common/geoposition.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
#include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h"
@@ -22,6 +21,7 @@
#include "content/browser/geolocation/mock_location_provider.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/common/geoposition.h"
#include "content/common/notification_details.h"
#include "content/common/notification_service.h"
#include "content/common/notification_type.h"
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h
index f178ce3..9b22cf8 100644
--- a/chrome/browser/history/history_backend.h
+++ b/chrome/browser/history/history_backend.h
@@ -21,7 +21,7 @@
#include "chrome/browser/history/thumbnail_database.h"
#include "chrome/browser/history/visit_tracker.h"
#include "chrome/browser/search_engines/template_url_id.h"
-#include "chrome/common/mru_cache.h"
+#include "content/common/mru_cache.h"
class BookmarkService;
struct DownloadCreateInfo;
diff --git a/chrome/browser/history/text_database_manager.cc b/chrome/browser/history/text_database_manager.cc
index c23158e..e884ec1 100644
--- a/chrome/browser/history/text_database_manager.cc
+++ b/chrome/browser/history/text_database_manager.cc
@@ -13,7 +13,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/history/history_publisher.h"
#include "chrome/browser/history/visit_database.h"
-#include "chrome/common/mru_cache.h"
+#include "content/common/mru_cache.h"
using base::Time;
using base::TimeDelta;
diff --git a/chrome/browser/history/text_database_manager.h b/chrome/browser/history/text_database_manager.h
index 673046f..50cfeb5 100644
--- a/chrome/browser/history/text_database_manager.h
+++ b/chrome/browser/history/text_database_manager.h
@@ -18,7 +18,7 @@
#include "chrome/browser/history/text_database.h"
#include "chrome/browser/history/query_parser.h"
#include "chrome/browser/history/url_database.h"
-#include "chrome/common/mru_cache.h"
+#include "content/common/mru_cache.h"
struct sqlite3;
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 4cb5a9a..b6b5601 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -51,10 +51,6 @@
'common/content_settings_types.h',
'common/devtools_messages.cc',
'common/devtools_messages.h',
- 'common/font_config_ipc_linux.cc',
- 'common/font_config_ipc_linux.h',
- 'common/geoposition.cc',
- 'common/geoposition.h',
'common/gfx_resource_provider.cc',
'common/gfx_resource_provider.h',
'common/guid.cc',
@@ -94,8 +90,6 @@
'common/switch_utils.h',
'common/time_format.cc',
'common/time_format.h',
- 'common/unix_domain_socket_posix.cc',
- 'common/unix_domain_socket_posix.h',
'common/win_safe_util.cc',
'common/win_safe_util.h',
],
@@ -165,8 +159,6 @@
'common/default_plugin.h',
'common/deprecated/event_sys-inl.h',
'common/deprecated/event_sys.h',
- 'common/desktop_notifications/active_notification_tracker.cc',
- 'common/desktop_notifications/active_notification_tracker.h',
'common/extensions/extension.cc',
'common/extensions/extension.h',
'common/extensions/extension_action.cc',
@@ -212,7 +204,6 @@
'common/jstemplate_builder.h',
'common/libxml_utils.cc',
'common/libxml_utils.h',
- 'common/mru_cache.h',
'common/native_web_keyboard_event.h',
'common/native_web_keyboard_event_linux.cc',
'common/native_web_keyboard_event_mac.mm',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 9afc613..164dbdd 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1711,7 +1711,6 @@
'common/common_param_traits_unittest.cc',
'common/content_settings_helper_unittest.cc',
'common/deprecated/event_sys_unittest.cc',
- 'common/desktop_notifications/active_notification_tracker_unittest.cc',
'common/extensions/extension_action_unittest.cc',
'common/extensions/extension_extent_unittest.cc',
'common/extensions/extension_file_util_unittest.cc',
@@ -1734,7 +1733,6 @@
'common/json_schema_validator_unittest_base.h',
'common/json_schema_validator_unittest.cc',
'common/json_value_serializer_unittest.cc',
- 'common/mru_cache_unittest.cc',
'common/multi_process_lock_unittest.cc',
'common/net/gaia/gaia_auth_fetcher_unittest.cc',
'common/net/gaia/gaia_auth_fetcher_unittest.h',
@@ -1825,6 +1823,7 @@
'../content/common/font_descriptor_mac_unittest.mm',
'../content/common/gpu_feature_flags_unittest.cc',
'../content/common/gpu_info_unittest.cc',
+ '../content/common/mru_cache_unittest.cc',
'../content/common/notification_service_unittest.cc',
'../content/common/property_bag_unittest.cc',
'../content/common/resource_dispatcher_unittest.cc',
@@ -1838,6 +1837,7 @@
'../content/gpu/gpu_info_collector_unittest.cc',
'../content/gpu/gpu_info_unittest_win.cc',
'../content/gpu/gpu_video_decoder_unittest.cc',
+ '../content/renderer/active_notification_tracker_unittest.cc',
'../content/renderer/audio_message_filter_unittest.cc',
'../content/renderer/media/audio_renderer_impl_unittest.cc',
'../testing/gtest_mac_unittest.mm',
diff --git a/chrome/common/common_param_traits.cc b/chrome/common/common_param_traits.cc
index 6297e641..6c0fc25 100644
--- a/chrome/common/common_param_traits.cc
+++ b/chrome/common/common_param_traits.cc
@@ -7,10 +7,10 @@
#include "base/time.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/content_settings.h"
-#include "chrome/common/geoposition.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/web_apps.h"
#include "content/common/common_param_traits.h"
+#include "content/common/geoposition.h"
#include "googleurl/src/gurl.h"
#include "printing/backend/print_backend.h"
#include "printing/native_metafile.h"
diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc
index 20387d0..7928032 100644
--- a/chrome/common/common_param_traits_unittest.cc
+++ b/chrome/common/common_param_traits_unittest.cc
@@ -8,8 +8,8 @@
#include "base/scoped_ptr.h"
#include "base/values.h"
#include "chrome/common/common_param_traits.h"
-#include "chrome/common/geoposition.h"
#include "content/common/common_param_traits.h"
+#include "content/common/geoposition.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_utils.h"
diff --git a/chrome/common/desktop_notifications/active_notification_tracker.cc b/chrome/common/desktop_notifications/active_notification_tracker.cc
deleted file mode 100644
index 3603103..0000000
--- a/chrome/common/desktop_notifications/active_notification_tracker.cc
+++ /dev/null
@@ -1,84 +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/common/desktop_notifications/active_notification_tracker.h"
-
-#include "base/message_loop.h"
-#include "base/scoped_ptr.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotification.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotificationPermissionCallback.h"
-
-using WebKit::WebNotification;
-using WebKit::WebNotificationPermissionCallback;
-
-ActiveNotificationTracker::ActiveNotificationTracker() {}
-
-ActiveNotificationTracker::~ActiveNotificationTracker() {}
-
-bool ActiveNotificationTracker::GetId(
- const WebNotification& notification, int& id) {
- ReverseTable::iterator iter = reverse_notification_table_.find(notification);
- if (iter == reverse_notification_table_.end())
- return false;
- id = iter->second;
- return true;
-}
-
-bool ActiveNotificationTracker::GetNotification(
- int id, WebNotification* notification) {
- WebNotification* lookup = notification_table_.Lookup(id);
- if (!lookup)
- return false;
-
- *notification = *lookup;
- return true;
-}
-
-int ActiveNotificationTracker::RegisterNotification(
- const WebKit::WebNotification& proxy) {
- WebNotification* notification = new WebNotification(proxy);
- int id = notification_table_.Add(notification);
- reverse_notification_table_[proxy] = id;
- return id;
-}
-
-void ActiveNotificationTracker::UnregisterNotification(int id) {
- // We want to free the notification after removing it from the table.
- scoped_ptr<WebNotification> notification(notification_table_.Lookup(id));
- notification_table_.Remove(id);
- DCHECK(notification.get());
- if (notification.get())
- reverse_notification_table_.erase(*notification);
-}
-
-void ActiveNotificationTracker::Clear() {
- while (!reverse_notification_table_.empty()) {
- ReverseTable::iterator iter = reverse_notification_table_.begin();
- UnregisterNotification((*iter).second);
- }
-}
-
-void ActiveNotificationTracker::DetachAll() {
- ReverseTable::iterator iter;
- for (iter = reverse_notification_table_.begin();
- iter != reverse_notification_table_.end();
- ++iter) {
- WebNotification notification(iter->first);
- notification.detachPresenter();
- }
-}
-
-WebNotificationPermissionCallback* ActiveNotificationTracker::GetCallback(
- int id) {
- return callback_table_.Lookup(id);
-}
-
-int ActiveNotificationTracker::RegisterPermissionRequest(
- WebNotificationPermissionCallback* callback) {
- return callback_table_.Add(callback);
-}
-
-void ActiveNotificationTracker::OnPermissionRequestComplete(int id) {
- callback_table_.Remove(id);
-}
diff --git a/chrome/common/desktop_notifications/active_notification_tracker.h b/chrome/common/desktop_notifications/active_notification_tracker.h
deleted file mode 100644
index 9610ce4..0000000
--- a/chrome/common/desktop_notifications/active_notification_tracker.h
+++ /dev/null
@@ -1,58 +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_COMMON_DESKTOP_NOTIFICATIONS_ACTIVE_NOTIFICATION_TRACKER_H_
-#define CHROME_COMMON_DESKTOP_NOTIFICATIONS_ACTIVE_NOTIFICATION_TRACKER_H_
-#pragma once
-
-#include <map>
-
-#include "base/basictypes.h"
-#include "base/id_map.h"
-#include "base/hash_tables.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebNotification.h"
-
-namespace WebKit {
-class WebNotificationPermissionCallback;
-}
-
-// This class manages the set of active Notification objects in either
-// a render or worker process. This class should be accessed only on
-// the main thread.
-class ActiveNotificationTracker {
- public:
- ActiveNotificationTracker();
- ~ActiveNotificationTracker();
-
- // Methods for tracking active notification objects.
- int RegisterNotification(const WebKit::WebNotification& notification);
- void UnregisterNotification(int id);
- bool GetId(const WebKit::WebNotification& notification, int& id);
- bool GetNotification(int id, WebKit::WebNotification* notification);
-
- // Methods for tracking active permission requests.
- int RegisterPermissionRequest(
- WebKit::WebNotificationPermissionCallback* callback);
- void OnPermissionRequestComplete(int id);
- WebKit::WebNotificationPermissionCallback* GetCallback(int id);
-
- // Clears out all active notifications. Useful on page navigation.
- void Clear();
-
- // Detaches all active notifications from their presenter. Necessary
- // when the Presenter is destroyed.
- void DetachAll();
-
- private:
- typedef std::map<WebKit::WebNotification, int> ReverseTable;
-
- // Tracking maps for active notifications and permission requests.
- IDMap<WebKit::WebNotification> notification_table_;
- ReverseTable reverse_notification_table_;
- IDMap<WebKit::WebNotificationPermissionCallback> callback_table_;
-
- DISALLOW_COPY_AND_ASSIGN(ActiveNotificationTracker);
-};
-
-#endif // CHROME_COMMON_DESKTOP_NOTIFICATIONS_ACTIVE_NOTIFICATION_TRACKER_H_
diff --git a/chrome/common/desktop_notifications/active_notification_tracker_unittest.cc b/chrome/common/desktop_notifications/active_notification_tracker_unittest.cc
deleted file mode 100644
index b741d35..0000000
--- a/chrome/common/desktop_notifications/active_notification_tracker_unittest.cc
+++ /dev/null
@@ -1,25 +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/common/desktop_notifications/active_notification_tracker.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-TEST(ActiveNotificationTrackerTest, TestLookupAndClear) {
- ActiveNotificationTracker tracker;
-
- WebKit::WebNotification notification1;
- int id1 = tracker.RegisterNotification(notification1);
-
- WebKit::WebNotification notification2;
- int id2 = tracker.RegisterNotification(notification2);
-
- WebKit::WebNotification result;
- tracker.GetNotification(id1, &result);
- EXPECT_TRUE(result == notification1);
-
- tracker.GetNotification(id2, &result);
- EXPECT_TRUE(result == notification2);
-
- tracker.Clear();
-}
diff --git a/chrome/common/font_config_ipc_linux.cc b/chrome/common/font_config_ipc_linux.cc
deleted file mode 100644
index a2e86a9..0000000
--- a/chrome/common/font_config_ipc_linux.cc
+++ /dev/null
@@ -1,110 +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/common/font_config_ipc_linux.h"
-
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-
-#include "base/pickle.h"
-#include "chrome/common/unix_domain_socket_posix.h"
-
-FontConfigIPC::FontConfigIPC(int fd)
- : fd_(fd) {
-}
-
-FontConfigIPC::~FontConfigIPC() {
- close(fd_);
-}
-
-bool FontConfigIPC::Match(std::string* result_family,
- unsigned* result_filefaceid,
- bool filefaceid_valid, unsigned filefaceid,
- const std::string& family,
- const void* characters, size_t characters_bytes,
- bool* is_bold, bool* is_italic) {
- if (family.length() > kMaxFontFamilyLength)
- return false;
-
- Pickle request;
- request.WriteInt(METHOD_MATCH);
- request.WriteBool(filefaceid_valid);
- if (filefaceid_valid)
- request.WriteUInt32(filefaceid);
-
- request.WriteBool(is_bold && *is_bold);
- request.WriteBool(is_bold && *is_italic);
-
- request.WriteUInt32(characters_bytes);
- if (characters_bytes)
- request.WriteBytes(characters, characters_bytes);
-
- request.WriteString(family);
-
- uint8_t reply_buf[512];
- const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf,
- sizeof(reply_buf), NULL,
- request);
- if (r == -1)
- return false;
-
- Pickle reply(reinterpret_cast<char*>(reply_buf), r);
- void* iter = NULL;
- bool result;
- if (!reply.ReadBool(&iter, &result))
- return false;
- if (!result)
- return false;
-
- uint32_t reply_filefaceid;
- std::string reply_family;
- bool resulting_bold, resulting_italic;
- if (!reply.ReadUInt32(&iter, &reply_filefaceid) ||
- !reply.ReadString(&iter, &reply_family) ||
- !reply.ReadBool(&iter, &resulting_bold) ||
- !reply.ReadBool(&iter, &resulting_italic)) {
- return false;
- }
-
- *result_filefaceid = reply_filefaceid;
- if (result_family)
- *result_family = reply_family;
-
- if (is_bold)
- *is_bold = resulting_bold;
- if (is_italic)
- *is_italic = resulting_italic;
-
- return true;
-}
-
-int FontConfigIPC::Open(unsigned filefaceid) {
- Pickle request;
- request.WriteInt(METHOD_OPEN);
- request.WriteUInt32(filefaceid);
-
- int result_fd = -1;
- uint8_t reply_buf[256];
- const ssize_t r = UnixDomainSocket::SendRecvMsg(fd_, reply_buf,
- sizeof(reply_buf),
- &result_fd, request);
-
- if (r == -1)
- return -1;
-
- Pickle reply(reinterpret_cast<char*>(reply_buf), r);
- bool result;
- void* iter = NULL;
- if (!reply.ReadBool(&iter, &result) ||
- !result) {
- if (result_fd)
- close(result_fd);
- return -1;
- }
-
- return result_fd;
-}
diff --git a/chrome/common/font_config_ipc_linux.h b/chrome/common/font_config_ipc_linux.h
deleted file mode 100644
index e478f6a..0000000
--- a/chrome/common/font_config_ipc_linux.h
+++ /dev/null
@@ -1,40 +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_COMMON_FONT_CONFIG_IPC_LINUX_H_
-#define CHROME_COMMON_FONT_CONFIG_IPC_LINUX_H_
-#pragma once
-
-#include "skia/ext/SkFontHost_fontconfig_impl.h"
-
-#include <string>
-
-// FontConfig implementation for Skia that proxies out of process to get out
-// of the sandbox. See http://code.google.com/p/chromium/wiki/LinuxSandboxIPC
-class FontConfigIPC : public FontConfigInterface {
- public:
- explicit FontConfigIPC(int fd);
- ~FontConfigIPC();
-
- // FontConfigInterface implementation.
- virtual bool Match(std::string* result_family,
- unsigned* result_filefaceid,
- bool filefaceid_valid,
- unsigned filefaceid,
- const std::string& family,
- const void* characters,
- size_t characters_bytes,
- bool* is_bold, bool* is_italic);
- virtual int Open(unsigned filefaceid);
-
- enum Method {
- METHOD_MATCH = 0,
- METHOD_OPEN = 1,
- };
-
- private:
- const int fd_;
-};
-
-#endif // CHROME_COMMON_FONT_CONFIG_IPC_LINUX_H_
diff --git a/chrome/common/geoposition.cc b/chrome/common/geoposition.cc
deleted file mode 100644
index e3a2020..0000000
--- a/chrome/common/geoposition.cc
+++ /dev/null
@@ -1,66 +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/common/geoposition.h"
-
-namespace {
-// Sentinel values to mark invalid data. (WebKit carries companion is_valid
-// bools for this purpose; we may eventually follow that approach, but
-// sentinels worked OK in the Gears code this is based on.)
-const double kBadLatitudeLongitude = 200;
-// Lowest point on land is at approximately -400 meters.
-const int kBadAltitude = -10000;
-const int kBadAccuracy = -1; // Accuracy must be non-negative.
-const int64 kBadTimestamp = kint64min;
-const int kBadHeading = -1; // Heading must be non-negative.
-const int kBadSpeed = -1;
-}
-
-Geoposition::Geoposition()
- : latitude(kBadLatitudeLongitude),
- longitude(kBadLatitudeLongitude),
- altitude(kBadAltitude),
- accuracy(kBadAccuracy),
- altitude_accuracy(kBadAccuracy),
- heading(kBadHeading),
- speed(kBadSpeed),
- error_code(ERROR_CODE_NONE) {
-}
-
-bool Geoposition::is_valid_latlong() const {
- return latitude >= -90.0 && latitude <= 90.0 &&
- longitude >= -180.0 && longitude <= 180.0;
-}
-
-bool Geoposition::is_valid_altitude() const {
- return altitude > kBadAltitude;
-}
-
-bool Geoposition::is_valid_accuracy() const {
- return accuracy >= 0.0;
-}
-
-bool Geoposition::is_valid_altitude_accuracy() const {
- return altitude_accuracy >= 0.0;
-}
-
-bool Geoposition::is_valid_heading() const {
- return heading >= 0 && heading <= 360;
-}
-
-bool Geoposition::is_valid_speed() const {
- return speed >= 0;
-}
-
-bool Geoposition::is_valid_timestamp() const {
- return !timestamp.is_null();
-}
-
-bool Geoposition::IsValidFix() const {
- return is_valid_latlong() && is_valid_accuracy() && is_valid_timestamp();
-}
-
-bool Geoposition::IsInitialized() const {
- return error_code != ERROR_CODE_NONE || IsValidFix();
-}
diff --git a/chrome/common/geoposition.h b/chrome/common/geoposition.h
deleted file mode 100644
index 6b19275..0000000
--- a/chrome/common/geoposition.h
+++ /dev/null
@@ -1,65 +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.
-
-// This file declares the Position structure, which is used to represent a
-// position fix. Originally derived from
-// http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h
-
-#ifndef CHROME_COMMON_GEOPOSITION_H_
-#define CHROME_COMMON_GEOPOSITION_H_
-#pragma once
-
-#include <string>
-#include "base/time.h"
-
-// The internal representation of a geo position. Some properties use different
-// types when passed to JavaScript.
-struct Geoposition {
- public:
- // Error codes for returning to JavaScript. These values are defined by the
- // W3C spec. Note that Gears does not use all of these codes, but we need
- // values for all of them to allow us to provide the constants on the error
- // object.
- enum ErrorCode {
- ERROR_CODE_NONE = 0, // Chrome addition
- ERROR_CODE_PERMISSION_DENIED = 1,
- ERROR_CODE_POSITION_UNAVAILABLE = 2,
- ERROR_CODE_TIMEOUT = 3,
- };
-
- Geoposition();
-
- bool is_valid_latlong() const;
- bool is_valid_altitude() const;
- bool is_valid_accuracy() const;
- bool is_valid_altitude_accuracy() const;
- bool is_valid_heading() const;
- bool is_valid_speed() const;
- bool is_valid_timestamp() const;
-
- // A valid fix has a valid latitude, longitude, accuracy and timestamp.
- bool IsValidFix() const;
-
- // A position is considered initialized if it has either a valid fix or
- // an error code other than NONE.
- bool IsInitialized() const;
-
- // These properties correspond to the JavaScript Position object.
- double latitude; // In degrees
- double longitude; // In degrees
- double altitude; // In metres
- double accuracy; // In metres
- double altitude_accuracy; // In metres
- double heading; // In degrees clockwise relative to the true north
- double speed; // In meters per second
- // Timestamp for this position fix object taken from the host computer's
- // system clock (i.e. from Time::Now(), not the source device's clock).
- base::Time timestamp;
-
- // These properties are returned to JavaScript as a PositionError object.
- ErrorCode error_code;
- std::string error_message; // Human-readable error message
-};
-
-#endif // CHROME_COMMON_GEOPOSITION_H_
diff --git a/chrome/common/mru_cache.h b/chrome/common/mru_cache.h
deleted file mode 100644
index b9b72d4..0000000
--- a/chrome/common/mru_cache.h
+++ /dev/null
@@ -1,253 +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.
-
-// This file contains a template for a Most Recently Used cache that allows
-// constant-time access to items using a key, but easy identification of the
-// least-recently-used items for removal. Each key can only be associated with
-// one payload item at a time.
-//
-// The key object will be stored twice, so it should support efficient copying.
-//
-// NOTE: While all operations are O(1), this code is written for
-// legibility rather than optimality. If future profiling identifies this as
-// a bottleneck, there is room for smaller values of 1 in the O(1). :]
-
-#ifndef CHROME_COMMON_MRU_CACHE_H__
-#define CHROME_COMMON_MRU_CACHE_H__
-#pragma once
-
-#include <list>
-#include <map>
-#include <utility>
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-
-// MRUCacheBase ----------------------------------------------------------------
-
-// Base class for the MRU cache specializations defined below.
-// The deletor will get called on all payloads that are being removed or
-// replaced.
-template <class KeyType, class PayloadType, class DeletorType>
-class MRUCacheBase {
- public:
- // The payload of the list. This maintains a copy of the key so we can
- // efficiently delete things given an element of the list.
- typedef std::pair<KeyType, PayloadType> value_type;
-
- private:
- typedef std::list<value_type> PayloadList;
- typedef std::map<KeyType, typename PayloadList::iterator> KeyIndex;
-
- public:
- typedef typename PayloadList::size_type size_type;
-
- typedef typename PayloadList::iterator iterator;
- typedef typename PayloadList::const_iterator const_iterator;
- typedef typename PayloadList::reverse_iterator reverse_iterator;
- typedef typename PayloadList::const_reverse_iterator const_reverse_iterator;
-
- enum { NO_AUTO_EVICT = 0 };
-
- // The max_size is the size at which the cache will prune its members to when
- // a new item is inserted. If the caller wants to manager this itself (for
- // example, maybe it has special work to do when something is evicted), it
- // can pass NO_AUTO_EVICT to not restrict the cache size.
- explicit MRUCacheBase(size_type max_size) : max_size_(max_size) {
- }
-
- virtual ~MRUCacheBase() {
- iterator i = begin();
- while (i != end())
- i = Erase(i);
- }
-
- // Inserts a payload item with the given key. If an existing item has
- // the same key, it is removed prior to insertion. An iterator indicating the
- // inserted item will be returned (this will always be the front of the list).
- //
- // The payload will be copied. In the case of an OwningMRUCache, this function
- // will take ownership of the pointer.
- iterator Put(const KeyType& key, const PayloadType& payload) {
- // Remove any existing payload with that key.
- typename KeyIndex::iterator index_iter = index_.find(key);
- if (index_iter != index_.end()) {
- // Erase the reference to it. This will call the deletor on the removed
- // element. The index reference will be replaced in the code below.
- Erase(index_iter->second);
- } else if (max_size_ != NO_AUTO_EVICT) {
- // New item is being inserted which might make it larger than the maximum
- // size: kick the oldest thing out if necessary.
- ShrinkToSize(max_size_ - 1);
- }
-
- ordering_.push_front(value_type(key, payload));
- index_[key] = ordering_.begin();
- return ordering_.begin();
- }
-
- // Retrieves the contents of the given key, or end() if not found. This method
- // has the side effect of moving the requested item to the front of the
- // recency list.
- //
- // TODO(brettw) We may want a const version of this function in the future.
- iterator Get(const KeyType& key) {
- typename KeyIndex::iterator index_iter = index_.find(key);
- if (index_iter == index_.end())
- return end();
- typename PayloadList::iterator iter = index_iter->second;
-
- // Move the touched item to the front of the recency ordering.
- ordering_.splice(ordering_.begin(), ordering_, iter);
- return ordering_.begin();
- }
-
- // Retrieves the payload associated with a given key and returns it via
- // result without affecting the ordering (unlike Get).
- //
- // TODO(brettw) We may want a const version of this function in the future.
- iterator Peek(const KeyType& key) {
- typename KeyIndex::const_iterator index_iter = index_.find(key);
- if (index_iter == index_.end())
- return end();
- return index_iter->second;
- }
-
- // Erases the item referenced by the given iterator. An iterator to the item
- // following it will be returned. The iterator must be valid.
- iterator Erase(iterator pos) {
- deletor_(pos->second);
- index_.erase(pos->first);
- return ordering_.erase(pos);
- }
-
- // MRUCache entries are often processed in reverse order, so we add this
- // convenience function (not typically defined by STL containers).
- reverse_iterator Erase(reverse_iterator pos) {
- // We have to actually give it the incremented iterator to delete, since
- // the forward iterator that base() returns is actually one past the item
- // being iterated over.
- return reverse_iterator(Erase((++pos).base()));
- }
-
- // Shrinks the cache so it only holds |new_size| items. If |new_size| is
- // bigger or equal to the current number of items, this will do nothing.
- void ShrinkToSize(size_type new_size) {
- for (size_type i = size(); i > new_size; i--)
- Erase(rbegin());
- }
-
- // Deletes everything from the cache.
- void Clear() {
- for (typename PayloadList::iterator i(ordering_.begin());
- i != ordering_.end(); ++i)
- deletor_(i->second);
- index_.clear();
- ordering_.clear();
- }
-
- // Returns the number of elements in the cache.
- size_type size() const {
- // We don't use ordering_.size() for the return value because
- // (as a linked list) it can be O(n).
- DCHECK(index_.size() == ordering_.size());
- return index_.size();
- }
-
- // Allows iteration over the list. Forward iteration starts with the most
- // recent item and works backwards.
- //
- // Note that since these iterators are actually iterators over a list, you
- // can keep them as you insert or delete things (as long as you don't delete
- // the one you are pointing to) and they will still be valid.
- iterator begin() { return ordering_.begin(); }
- const_iterator begin() const { ordering_.begin(); }
- iterator end() { return ordering_.end(); }
- const_iterator end() const { return ordering_.end(); }
-
- reverse_iterator rbegin() { return ordering_.rbegin(); }
- const_reverse_iterator rbegin() const { ordering_.rbegin(); }
- reverse_iterator rend() { return ordering_.rend(); }
- const_reverse_iterator rend() const { return ordering_.rend(); }
-
- bool empty() const { return ordering_.empty(); }
-
- private:
- PayloadList ordering_;
- KeyIndex index_;
-
- size_type max_size_;
-
- DeletorType deletor_;
-
- DISALLOW_COPY_AND_ASSIGN(MRUCacheBase);
-};
-
-// MRUCache --------------------------------------------------------------------
-
-// A functor that does nothing. Used by the MRUCache.
-template<class PayloadType>
-class MRUCacheNullDeletor {
- public:
- void operator()(PayloadType& payload) {
- }
-};
-
-// A container that does not do anything to free its data. Use this when storing
-// value types (as opposed to pointers) in the list.
-template <class KeyType, class PayloadType>
-class MRUCache : public MRUCacheBase<KeyType,
- PayloadType,
- MRUCacheNullDeletor<PayloadType> > {
- private:
- typedef MRUCacheBase<KeyType, PayloadType,
- MRUCacheNullDeletor<PayloadType> > ParentType;
-
- public:
- // See MRUCacheBase, noting the possibility of using NO_AUTO_EVICT.
- explicit MRUCache(typename ParentType::size_type max_size)
- : ParentType(max_size) {
- }
- virtual ~MRUCache() {
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MRUCache);
-};
-
-// OwningMRUCache --------------------------------------------------------------
-
-template<class PayloadType>
-class MRUCachePointerDeletor {
- public:
- void operator()(PayloadType& payload) {
- delete payload;
- }
-};
-
-// A cache that owns the payload type, which must be a non-const pointer type.
-// The pointers will be deleted when they are removed, replaced, or when the
-// cache is destroyed.
-template <class KeyType, class PayloadType>
-class OwningMRUCache
- : public MRUCacheBase<KeyType,
- PayloadType,
- MRUCachePointerDeletor<PayloadType> > {
- private:
- typedef MRUCacheBase<KeyType, PayloadType,
- MRUCachePointerDeletor<PayloadType> > ParentType;
-
- public:
- // See MRUCacheBase, noting the possibility of using NO_AUTO_EVICT.
- explicit OwningMRUCache(typename ParentType::size_type max_size)
- : ParentType(max_size) {
- }
- virtual ~OwningMRUCache() {
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OwningMRUCache);
-};
-
-#endif // CHROME_COMMON_MRU_CACHE_H__
diff --git a/chrome/common/mru_cache_unittest.cc b/chrome/common/mru_cache_unittest.cc
deleted file mode 100644
index 7cfb7d8..0000000
--- a/chrome/common/mru_cache_unittest.cc
+++ /dev/null
@@ -1,253 +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 "base/basictypes.h"
-#include "chrome/common/mru_cache.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-int cached_item_live_count = 0;
-
-struct CachedItem {
- CachedItem() : value(0) {
- cached_item_live_count++;
- }
-
- explicit CachedItem(int new_value) : value(new_value) {
- cached_item_live_count++;
- }
-
- explicit CachedItem(const CachedItem& other) : value(other.value) {
- cached_item_live_count++;
- }
-
- ~CachedItem() {
- cached_item_live_count--;
- }
-
- int value;
-};
-
-} // namespace
-
-TEST(MRUCacheTest, Basic) {
- typedef MRUCache<int, CachedItem> Cache;
- Cache cache(Cache::NO_AUTO_EVICT);
-
- // Check failure conditions
- {
- CachedItem test_item;
- EXPECT_TRUE(cache.Get(0) == cache.end());
- EXPECT_TRUE(cache.Peek(0) == cache.end());
- }
-
- static const int kItem1Key = 5;
- CachedItem item1(10);
- Cache::iterator inserted_item = cache.Put(kItem1Key, item1);
- EXPECT_EQ(1U, cache.size());
-
- // Check that item1 was properly inserted.
- {
- Cache::iterator found = cache.Get(kItem1Key);
- EXPECT_TRUE(inserted_item == cache.begin());
- EXPECT_TRUE(found != cache.end());
-
- found = cache.Peek(kItem1Key);
- EXPECT_TRUE(found != cache.end());
-
- EXPECT_EQ(kItem1Key, found->first);
- EXPECT_EQ(item1.value, found->second.value);
- }
-
- static const int kItem2Key = 7;
- CachedItem item2(12);
- cache.Put(kItem2Key, item2);
- EXPECT_EQ(2U, cache.size());
-
- // Check that item1 is the oldest since item2 was added afterwards.
- {
- Cache::reverse_iterator oldest = cache.rbegin();
- ASSERT_TRUE(oldest != cache.rend());
- EXPECT_EQ(kItem1Key, oldest->first);
- EXPECT_EQ(item1.value, oldest->second.value);
- }
-
- // Check that item1 is still accessible by key.
- {
- Cache::iterator test_item = cache.Get(kItem1Key);
- ASSERT_TRUE(test_item != cache.end());
- EXPECT_EQ(kItem1Key, test_item->first);
- EXPECT_EQ(item1.value, test_item->second.value);
- }
-
- // Check that retrieving item1 pushed item2 to oldest.
- {
- Cache::reverse_iterator oldest = cache.rbegin();
- ASSERT_TRUE(oldest != cache.rend());
- EXPECT_EQ(kItem2Key, oldest->first);
- EXPECT_EQ(item2.value, oldest->second.value);
- }
-
- // Remove the oldest item and check that item1 is now the only member.
- {
- Cache::reverse_iterator next = cache.Erase(cache.rbegin());
-
- EXPECT_EQ(1U, cache.size());
-
- EXPECT_TRUE(next == cache.rbegin());
- EXPECT_EQ(kItem1Key, next->first);
- EXPECT_EQ(item1.value, next->second.value);
-
- cache.Erase(cache.begin());
- EXPECT_EQ(0U, cache.size());
- }
-
- // Check that Clear() works properly.
- cache.Put(kItem1Key, item1);
- cache.Put(kItem2Key, item2);
- EXPECT_EQ(2U, cache.size());
- cache.Clear();
- EXPECT_EQ(0U, cache.size());
-}
-
-TEST(MRUCacheTest, GetVsPeek) {
- typedef MRUCache<int, CachedItem> Cache;
- Cache cache(Cache::NO_AUTO_EVICT);
-
- static const int kItem1Key = 1;
- CachedItem item1(10);
- cache.Put(kItem1Key, item1);
-
- static const int kItem2Key = 2;
- CachedItem item2(20);
- cache.Put(kItem2Key, item2);
-
- // This should do nothing since the size is bigger than the number of items.
- cache.ShrinkToSize(100);
-
- // Check that item1 starts out as oldest
- {
- Cache::reverse_iterator iter = cache.rbegin();
- ASSERT_TRUE(iter != cache.rend());
- EXPECT_EQ(kItem1Key, iter->first);
- EXPECT_EQ(item1.value, iter->second.value);
- }
-
- // Check that Peek doesn't change ordering
- {
- Cache::iterator peekiter = cache.Peek(kItem1Key);
- ASSERT_TRUE(peekiter != cache.end());
-
- Cache::reverse_iterator iter = cache.rbegin();
- ASSERT_TRUE(iter != cache.rend());
- EXPECT_EQ(kItem1Key, iter->first);
- EXPECT_EQ(item1.value, iter->second.value);
- }
-}
-
-TEST(MRUCacheTest, KeyReplacement) {
- typedef MRUCache<int, CachedItem> Cache;
- Cache cache(Cache::NO_AUTO_EVICT);
-
- static const int kItem1Key = 1;
- CachedItem item1(10);
- cache.Put(kItem1Key, item1);
-
- static const int kItem2Key = 2;
- CachedItem item2(20);
- cache.Put(kItem2Key, item2);
-
- static const int kItem3Key = 3;
- CachedItem item3(30);
- cache.Put(kItem3Key, item3);
-
- static const int kItem4Key = 4;
- CachedItem item4(40);
- cache.Put(kItem4Key, item4);
-
- CachedItem item5(50);
- cache.Put(kItem3Key, item5);
-
- EXPECT_EQ(4U, cache.size());
- for (int i = 0; i < 3; ++i) {
- Cache::reverse_iterator iter = cache.rbegin();
- ASSERT_TRUE(iter != cache.rend());
- }
-
- // Make it so only the most important element is there.
- cache.ShrinkToSize(1);
-
- Cache::iterator iter = cache.begin();
- EXPECT_EQ(kItem3Key, iter->first);
- EXPECT_EQ(item5.value, iter->second.value);
-}
-
-// Make sure that the owning version release its pointers properly.
-TEST(MRUCacheTest, Owning) {
- typedef OwningMRUCache<int, CachedItem*> Cache;
- Cache cache(Cache::NO_AUTO_EVICT);
-
- int initial_count = cached_item_live_count;
-
- // First insert and item and then overwrite it.
- static const int kItem1Key = 1;
- cache.Put(kItem1Key, new CachedItem(20));
- cache.Put(kItem1Key, new CachedItem(22));
-
- // There should still be one item, and one extra live item.
- Cache::iterator iter = cache.Get(kItem1Key);
- EXPECT_EQ(1U, cache.size());
- EXPECT_TRUE(iter != cache.end());
- EXPECT_EQ(initial_count + 1, cached_item_live_count);
-
- // Now remove it.
- cache.Erase(cache.begin());
- EXPECT_EQ(initial_count, cached_item_live_count);
-
- // Now try another cache that goes out of scope to make sure its pointers
- // go away.
- {
- Cache cache2(Cache::NO_AUTO_EVICT);
- cache2.Put(1, new CachedItem(20));
- cache2.Put(2, new CachedItem(20));
- }
-
- // There should be no objects leaked.
- EXPECT_EQ(initial_count, cached_item_live_count);
-
- // Check that Clear() also frees things correctly.
- {
- Cache cache2(Cache::NO_AUTO_EVICT);
- cache2.Put(1, new CachedItem(20));
- cache2.Put(2, new CachedItem(20));
- EXPECT_EQ(initial_count + 2, cached_item_live_count);
- cache2.Clear();
- EXPECT_EQ(initial_count, cached_item_live_count);
- }
-}
-
-TEST(MRUCacheTest, AutoEvict) {
- typedef OwningMRUCache<int, CachedItem*> Cache;
- static const Cache::size_type kMaxSize = 3;
-
- int initial_count = cached_item_live_count;
-
- {
- Cache cache(kMaxSize);
-
- static const int kItem1Key = 1, kItem2Key = 2, kItem3Key = 3, kItem4Key = 4;
- cache.Put(kItem1Key, new CachedItem(20));
- cache.Put(kItem2Key, new CachedItem(21));
- cache.Put(kItem3Key, new CachedItem(22));
- cache.Put(kItem4Key, new CachedItem(23));
-
- // The cache should only have kMaxSize items in it even though we inserted
- // more.
- EXPECT_EQ(kMaxSize, cache.size());
- }
-
- // There should be no objects leaked.
- EXPECT_EQ(initial_count, cached_item_live_count);
-}
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index db74cb8..e34f1e9 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -28,7 +28,6 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_extent.h"
#include "chrome/common/extensions/url_pattern.h"
-#include "chrome/common/geoposition.h"
#include "chrome/common/instant_types.h"
#include "chrome/common/nacl_types.h"
#include "chrome/common/page_transition_types.h"
@@ -41,6 +40,7 @@
#include "chrome/common/webkit_param_traits.h"
#include "chrome/common/window_container_type.h"
#include "content/common/common_param_traits.h"
+#include "content/common/geoposition.h"
#include "content/common/notification_type.h"
#include "content/common/resource_response.h"
#include "ipc/ipc_channel_handle.h"
diff --git a/chrome/common/unix_domain_socket_posix.cc b/chrome/common/unix_domain_socket_posix.cc
deleted file mode 100644
index 6bd387b..0000000
--- a/chrome/common/unix_domain_socket_posix.cc
+++ /dev/null
@@ -1,146 +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/common/unix_domain_socket_posix.h"
-
-#include <errno.h>
-#include <unistd.h>
-#include <sys/uio.h>
-#include <sys/socket.h>
-
-#include "base/eintr_wrapper.h"
-#include "base/logging.h"
-#include "base/pickle.h"
-
-// static
-bool UnixDomainSocket::SendMsg(int fd,
- const void* buf,
- size_t length,
- const std::vector<int>& fds) {
- struct msghdr msg;
- memset(&msg, 0, sizeof(msg));
- struct iovec iov = {const_cast<void*>(buf), length};
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
-
- char* control_buffer = NULL;
- if (fds.size()) {
- const unsigned control_len = CMSG_SPACE(sizeof(int) * fds.size());
- control_buffer = new char[control_len];
-
- struct cmsghdr *cmsg;
- msg.msg_control = control_buffer;
- msg.msg_controllen = control_len;
- cmsg = CMSG_FIRSTHDR(&msg);
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- cmsg->cmsg_len = CMSG_LEN(sizeof(int) * fds.size());
- memcpy(CMSG_DATA(cmsg), &fds[0], sizeof(int) * fds.size());
- msg.msg_controllen = cmsg->cmsg_len;
- }
-
- const ssize_t r = HANDLE_EINTR(sendmsg(fd, &msg, 0));
- const bool ret = static_cast<ssize_t>(length) == r;
- delete[] control_buffer;
- return ret;
-}
-
-// static
-ssize_t UnixDomainSocket::RecvMsg(int fd,
- void* buf,
- size_t length,
- std::vector<int>* fds) {
- static const unsigned kMaxDescriptors = 16;
-
- fds->clear();
-
- struct msghdr msg;
- memset(&msg, 0, sizeof(msg));
- struct iovec iov = {buf, length};
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
-
- char control_buffer[CMSG_SPACE(sizeof(int) * kMaxDescriptors)];
- msg.msg_control = control_buffer;
- msg.msg_controllen = sizeof(control_buffer);
-
- const ssize_t r = HANDLE_EINTR(recvmsg(fd, &msg, 0));
- if (r == -1)
- return -1;
-
- int* wire_fds = NULL;
- unsigned wire_fds_len = 0;
-
- if (msg.msg_controllen > 0) {
- struct cmsghdr* cmsg;
- for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
- if (cmsg->cmsg_level == SOL_SOCKET &&
- cmsg->cmsg_type == SCM_RIGHTS) {
- const unsigned payload_len = cmsg->cmsg_len - CMSG_LEN(0);
- DCHECK(payload_len % sizeof(int) == 0);
- wire_fds = reinterpret_cast<int*>(CMSG_DATA(cmsg));
- wire_fds_len = payload_len / sizeof(int);
- break;
- }
- }
- }
-
- if (msg.msg_flags & MSG_TRUNC || msg.msg_flags & MSG_CTRUNC) {
- for (unsigned i = 0; i < wire_fds_len; ++i)
- close(wire_fds[i]);
- errno = EMSGSIZE;
- return -1;
- }
-
- fds->resize(wire_fds_len);
- memcpy(&(*fds)[0], wire_fds, sizeof(int) * wire_fds_len);
-
- return r;
-}
-
-// static
-ssize_t UnixDomainSocket::SendRecvMsg(int fd,
- uint8_t* reply,
- unsigned max_reply_len,
- int* result_fd,
- const Pickle& request) {
- int fds[2];
-
- // This socketpair is only used for the IPC and is cleaned up before
- // returning.
- if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) == -1)
- return false;
-
- std::vector<int> fd_vector;
- fd_vector.push_back(fds[1]);
- if (!SendMsg(fd, request.data(), request.size(), fd_vector)) {
- close(fds[0]);
- close(fds[1]);
- return -1;
- }
- close(fds[1]);
-
- fd_vector.clear();
- const ssize_t reply_len = RecvMsg(fds[0], reply, max_reply_len, &fd_vector);
- close(fds[0]);
- if (reply_len == -1)
- return -1;
-
- if ((!fd_vector.empty() && result_fd == NULL) || fd_vector.size() > 1) {
- for (std::vector<int>::const_iterator
- i = fd_vector.begin(); i != fd_vector.end(); ++i) {
- close(*i);
- }
-
- NOTREACHED();
-
- return -1;
- }
-
- if (result_fd)
- *result_fd = fd_vector.empty() ? -1 : fd_vector[0];
-
- return reply_len;
-}
-
diff --git a/chrome/common/unix_domain_socket_posix.h b/chrome/common/unix_domain_socket_posix.h
deleted file mode 100644
index 405ca95..0000000
--- a/chrome/common/unix_domain_socket_posix.h
+++ /dev/null
@@ -1,54 +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_COMMON_UNIX_DOMAIN_SOCKET_POSIX_H_
-#define CHROME_COMMON_UNIX_DOMAIN_SOCKET_POSIX_H_
-#pragma once
-
-#include <stdint.h>
-#include <sys/types.h>
-#include <vector>
-
-class Pickle;
-
-class UnixDomainSocket {
- public:
- // Use sendmsg to write the given msg and include a vector of file
- // descriptors. Returns true if successful.
- static bool SendMsg(int fd,
- const void* msg,
- size_t length,
- const std::vector<int>& fds);
-
- // Use recvmsg to read a message and an array of file descriptors. Returns
- // -1 on failure. Note: will read, at most, 16 descriptors.
- static ssize_t RecvMsg(int fd,
- void* msg,
- size_t length,
- std::vector<int>* fds);
-
- // Perform a sendmsg/recvmsg pair.
- // 1. This process creates a UNIX DGRAM socketpair.
- // 2. This proces writes a request to |fd| with an SCM_RIGHTS control
- // message containing on end of the fresh socket pair.
- // 3. This process blocks reading from the other end of the fresh
- // socketpair.
- // 4. The target process receives the request, processes it and writes the
- // reply to the end of the socketpair contained in the request.
- // 5. This process wakes up and continues.
- //
- // fd: descriptor to send the request on
- // reply: buffer for the reply
- // reply_len: size of |reply|
- // result_fd: (may be NULL) the file descriptor returned in the reply
- // (if any)
- // request: the bytes to send in the request
- static ssize_t SendRecvMsg(int fd,
- uint8_t* reply,
- unsigned reply_len,
- int* result_fd,
- const Pickle& request);
-};
-
-#endif // CHROME_COMMON_UNIX_DOMAIN_SOCKET_POSIX_H_
diff --git a/chrome/renderer/renderer_sandbox_support_linux.cc b/chrome/renderer/renderer_sandbox_support_linux.cc
index f71f52d..c99d996 100644
--- a/chrome/renderer/renderer_sandbox_support_linux.cc
+++ b/chrome/renderer/renderer_sandbox_support_linux.cc
@@ -12,7 +12,7 @@
#include "base/scoped_ptr.h"
#include "chrome/common/chrome_descriptors.h"
#include "chrome/common/sandbox_methods_linux.h"
-#include "chrome/common/unix_domain_socket_posix.h"
+#include "content/common/unix_domain_socket_posix.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebFontRenderStyle.h"