Title: [89707] trunk/Source/WebCore
Revision
89707
Author
[email protected]
Date
2011-06-24 15:05:16 -0700 (Fri, 24 Jun 2011)

Log Message

2011-06-24  Tony Chang  <[email protected]>

        Reviewed by Adam Barth.

        Pass Strings by const reference to functions
        https://bugs.webkit.org/show_bug.cgi?id=63341

        Note that since Strings hold a RefPtr to StringImpl, passing Strings
        by value isn't horrible, but it does cause ref count churn and using
        const references is more consistent with the rest of the code base.

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::addHTTPOriginIfNeeded): Rework the code to not
            change the value of the passed in String.
        * loader/FrameLoader.h:
        * platform/win/ClipboardUtilitiesWin.cpp:
        (WebCore::setFileDescriptorData):
        * platform/win/ClipboardUtilitiesWin.h:
        * storage/DatabaseTracker.h:
        * storage/IDBLevelDBBackingStore.cpp:
        (WebCore::IDBLevelDBBackingStore::IDBLevelDBBackingStore):
        * storage/IDBLevelDBBackingStore.h:
        * storage/IDBSQLiteBackingStore.cpp:
        (WebCore::IDBSQLiteBackingStore::IDBSQLiteBackingStore):
        * storage/IDBSQLiteBackingStore.h:
        * storage/chromium/DatabaseTrackerChromium.cpp:
        (WebCore::DatabaseTracker::getOpenDatabases):
        * svg/SVGPaint.cpp:
        (WebCore::SVGPaint::SVGPaint):
        * svg/SVGPaint.h:
        * svg/animation/SMILTimeContainer.cpp:
        (WebCore::SMILTimeContainer::updateAnimations):
        * svg/animation/SMILTimeContainer.h:
        * websockets/ThreadableWebSocketChannelClientWrapper.cpp:
        (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback):
        * websockets/ThreadableWebSocketChannelClientWrapper.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (89706 => 89707)


--- trunk/Source/WebCore/ChangeLog	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/ChangeLog	2011-06-24 22:05:16 UTC (rev 89707)
@@ -1,3 +1,40 @@
+2011-06-24  Tony Chang  <[email protected]>
+
+        Reviewed by Adam Barth.
+
+        Pass Strings by const reference to functions
+        https://bugs.webkit.org/show_bug.cgi?id=63341
+
+        Note that since Strings hold a RefPtr to StringImpl, passing Strings
+        by value isn't horrible, but it does cause ref count churn and using
+        const references is more consistent with the rest of the code base.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::addHTTPOriginIfNeeded): Rework the code to not
+            change the value of the passed in String.
+        * loader/FrameLoader.h:
+        * platform/win/ClipboardUtilitiesWin.cpp:
+        (WebCore::setFileDescriptorData):
+        * platform/win/ClipboardUtilitiesWin.h:
+        * storage/DatabaseTracker.h:
+        * storage/IDBLevelDBBackingStore.cpp:
+        (WebCore::IDBLevelDBBackingStore::IDBLevelDBBackingStore):
+        * storage/IDBLevelDBBackingStore.h:
+        * storage/IDBSQLiteBackingStore.cpp:
+        (WebCore::IDBSQLiteBackingStore::IDBSQLiteBackingStore):
+        * storage/IDBSQLiteBackingStore.h:
+        * storage/chromium/DatabaseTrackerChromium.cpp:
+        (WebCore::DatabaseTracker::getOpenDatabases):
+        * svg/SVGPaint.cpp:
+        (WebCore::SVGPaint::SVGPaint):
+        * svg/SVGPaint.h:
+        * svg/animation/SMILTimeContainer.cpp:
+        (WebCore::SMILTimeContainer::updateAnimations):
+        * svg/animation/SMILTimeContainer.h:
+        * websockets/ThreadableWebSocketChannelClientWrapper.cpp:
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback):
+        * websockets/ThreadableWebSocketChannelClientWrapper.h:
+
 2011-06-24  Abhishek Arya  <[email protected]>
 
         Reviewed by Darin Adler.

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (89706 => 89707)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2011-06-24 22:05:16 UTC (rev 89707)
@@ -2526,7 +2526,7 @@
     request.setResponseContentDispositionEncodingFallbackArray("UTF-8", activeDocumentLoader()->writer()->deprecatedFrameEncoding(), settings ? settings->defaultTextEncodingName() : String());
 }
 
-void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, String origin)
+void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const String& origin)
 {
     if (!request.httpOrigin().isEmpty())
         return;  // Request already has an Origin header.
@@ -2546,7 +2546,8 @@
     if (origin.isEmpty()) {
         // If we don't know what origin header to attach, we attach the value
         // for an empty origin.
-        origin = SecurityOrigin::createEmpty()->toString();
+        request.setHTTPOrigin(SecurityOrigin::createEmpty()->toString());
+        return;
     }
 
     request.setHTTPOrigin(origin);

Modified: trunk/Source/WebCore/loader/FrameLoader.h (89706 => 89707)


--- trunk/Source/WebCore/loader/FrameLoader.h	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/loader/FrameLoader.h	2011-06-24 22:05:16 UTC (rev 89707)
@@ -202,7 +202,7 @@
     void addExtraFieldsToSubresourceRequest(ResourceRequest&);
     void addExtraFieldsToMainResourceRequest(ResourceRequest&);
     
-    static void addHTTPOriginIfNeeded(ResourceRequest&, String origin);
+    static void addHTTPOriginIfNeeded(ResourceRequest&, const String& origin);
 
     FrameLoaderClient* client() const { return m_client; }
 

Modified: trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp (89706 => 89707)


--- trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp	2011-06-24 22:05:16 UTC (rev 89707)
@@ -408,7 +408,7 @@
     ::ReleaseStgMedium(&store);
 }
 
-void setFileDescriptorData(IDataObject* dataObject, int size, String pathname)
+void setFileDescriptorData(IDataObject* dataObject, int size, const String& pathname)
 {
     STGMEDIUM medium = { 0 };
     medium.tymed = TYMED_HGLOBAL;

Modified: trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.h (89706 => 89707)


--- trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.h	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.h	2011-06-24 22:05:16 UTC (rev 89707)
@@ -80,7 +80,7 @@
 void setClipboardData(IDataObject*, UINT format, const Vector<String>& dataStrings);
 void getFileDescriptorData(IDataObject*, int& size, String& pathname);
 void getFileContentData(IDataObject*, int size, void* dataBlob);
-void setFileDescriptorData(IDataObject*, int size, String pathname);
+void setFileDescriptorData(IDataObject*, int size, const String& pathname);
 void setFileContentData(IDataObject*, int size, void* dataBlob);
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/storage/DatabaseTracker.h (89706 => 89707)


--- trunk/Source/WebCore/storage/DatabaseTracker.h	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/storage/DatabaseTracker.h	2011-06-24 22:05:16 UTC (rev 89707)
@@ -173,7 +173,7 @@
     static void notifyDatabasesChanged(void*);
 #else
 public:
-    void getOpenDatabases(String originIdentifier, const String& name, HashSet<RefPtr<AbstractDatabase> >* databases);
+    void getOpenDatabases(const String& originIdentifier, const String& name, HashSet<RefPtr<AbstractDatabase> >* databases);
 
 private:
     typedef HashSet<AbstractDatabase*> DatabaseSet;

Modified: trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp (89706 => 89707)


--- trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp	2011-06-24 22:05:16 UTC (rev 89707)
@@ -115,7 +115,7 @@
     return true;
 }
 
-IDBLevelDBBackingStore::IDBLevelDBBackingStore(String identifier, IDBFactoryBackendImpl* factory, PassOwnPtr<LevelDBDatabase> db)
+IDBLevelDBBackingStore::IDBLevelDBBackingStore(const String& identifier, IDBFactoryBackendImpl* factory, PassOwnPtr<LevelDBDatabase> db)
     : m_identifier(identifier)
     , m_factory(factory)
     , m_db(db)

Modified: trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h (89706 => 89707)


--- trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h	2011-06-24 22:05:16 UTC (rev 89707)
@@ -79,7 +79,7 @@
     static bool backingStoreExists(SecurityOrigin*, const String& pathBase);
 
 private:
-    IDBLevelDBBackingStore(String identifier, IDBFactoryBackendImpl*, PassOwnPtr<LevelDBDatabase>);
+    IDBLevelDBBackingStore(const String& identifier, IDBFactoryBackendImpl*, PassOwnPtr<LevelDBDatabase>);
 
     String m_identifier;
     RefPtr<IDBFactoryBackendImpl> m_factory;

Modified: trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp (89706 => 89707)


--- trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp	2011-06-24 22:05:16 UTC (rev 89707)
@@ -39,7 +39,7 @@
 
 namespace WebCore {
 
-IDBSQLiteBackingStore::IDBSQLiteBackingStore(String identifier, IDBFactoryBackendImpl* factory)
+IDBSQLiteBackingStore::IDBSQLiteBackingStore(const String& identifier, IDBFactoryBackendImpl* factory)
     : m_identifier(identifier)
     , m_factory(factory)
 {

Modified: trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h (89706 => 89707)


--- trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h	2011-06-24 22:05:16 UTC (rev 89707)
@@ -74,7 +74,7 @@
     static bool backingStoreExists(SecurityOrigin*, const String& pathBase);
 
 private:
-    IDBSQLiteBackingStore(String identifier, IDBFactoryBackendImpl*);
+    IDBSQLiteBackingStore(const String& identifier, IDBFactoryBackendImpl*);
 
     SQLiteDatabase m_db;
     String m_identifier;

Modified: trunk/Source/WebCore/storage/chromium/DatabaseTrackerChromium.cpp (89706 => 89707)


--- trunk/Source/WebCore/storage/chromium/DatabaseTrackerChromium.cpp	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/storage/chromium/DatabaseTrackerChromium.cpp	2011-06-24 22:05:16 UTC (rev 89707)
@@ -152,7 +152,7 @@
     getOpenDatabases(origin->databaseIdentifier(), name, databases);
 }
 
-void DatabaseTracker::getOpenDatabases(String originIdentifier, const String& name, HashSet<RefPtr<AbstractDatabase> >* databases)
+void DatabaseTracker::getOpenDatabases(const String& originIdentifier, const String& name, HashSet<RefPtr<AbstractDatabase> >* databases)
 {
     MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard);
     if (!m_openDatabaseMap)

Modified: trunk/Source/WebCore/svg/SVGPaint.cpp (89706 => 89707)


--- trunk/Source/WebCore/svg/SVGPaint.cpp	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/svg/SVGPaint.cpp	2011-06-24 22:05:16 UTC (rev 89707)
@@ -53,7 +53,7 @@
     return SVGColor::SVG_COLORTYPE_UNKNOWN;
 }
 
-SVGPaint::SVGPaint(const SVGPaintType& paintType, String uri)
+SVGPaint::SVGPaint(const SVGPaintType& paintType, const String& uri)
     : SVGColor(colorTypeForPaintType(paintType))
     , m_paintType(paintType)
     , m_uri(uri)

Modified: trunk/Source/WebCore/svg/SVGPaint.h (89706 => 89707)


--- trunk/Source/WebCore/svg/SVGPaint.h	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/svg/SVGPaint.h	2011-06-24 22:05:16 UTC (rev 89707)
@@ -104,7 +104,7 @@
     }
 
 private:
-    SVGPaint(const SVGPaintType&, String uri = String());
+    SVGPaint(const SVGPaintType&, const String& uri = String());
 
     virtual bool isSVGPaint() const { return true; }
     virtual String cssText() const;

Modified: trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp (89706 => 89707)


--- trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp	2011-06-24 22:05:16 UTC (rev 89707)
@@ -219,7 +219,7 @@
     updateAnimations(elapsed(), newTime, elementId);
 }
 
-void SMILTimeContainer::updateAnimations(SMILTime elapsed, double nextManualSampleTime, String nextSamplingTarget)
+void SMILTimeContainer::updateAnimations(SMILTime elapsed, double nextManualSampleTime, const String& nextSamplingTarget)
 {
     SMILTime earliersFireTime = SMILTime::unresolved();
 

Modified: trunk/Source/WebCore/svg/animation/SMILTimeContainer.h (89706 => 89707)


--- trunk/Source/WebCore/svg/animation/SMILTimeContainer.h	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/svg/animation/SMILTimeContainer.h	2011-06-24 22:05:16 UTC (rev 89707)
@@ -70,7 +70,7 @@
     
     void timerFired(Timer<SMILTimeContainer>*);
     void startTimer(SMILTime fireTime, SMILTime minimumDelay = 0);
-    void updateAnimations(SMILTime elapsed, double nextManualSampleTime = 0, String nextSamplingTarget = String());
+    void updateAnimations(SMILTime elapsed, double nextManualSampleTime = 0, const String& nextSamplingTarget = String());
     
     void updateDocumentOrderIndexes();
     void sortByPriority(Vector<SVGSMILElement*>& smilElements, SMILTime elapsed);

Modified: trunk/Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.cpp (89706 => 89707)


--- trunk/Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.cpp	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.cpp	2011-06-24 22:05:16 UTC (rev 89707)
@@ -151,7 +151,7 @@
         wrapper->m_client->didConnect();
 }
 
-void ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback(ScriptExecutionContext* context, ThreadableWebSocketChannelClientWrapper* wrapper, String message)
+void ThreadableWebSocketChannelClientWrapper::didReceiveMessageCallback(ScriptExecutionContext* context, ThreadableWebSocketChannelClientWrapper* wrapper, const String& message)
 {
     ASSERT_UNUSED(context, !context);
     if (wrapper->m_client)

Modified: trunk/Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h (89706 => 89707)


--- trunk/Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h	2011-06-24 22:03:55 UTC (rev 89706)
+++ trunk/Source/WebCore/websockets/ThreadableWebSocketChannelClientWrapper.h	2011-06-24 22:05:16 UTC (rev 89707)
@@ -74,7 +74,7 @@
 
     void processPendingTasks();
     static void didConnectCallback(ScriptExecutionContext*, ThreadableWebSocketChannelClientWrapper*);
-    static void didReceiveMessageCallback(ScriptExecutionContext*, ThreadableWebSocketChannelClientWrapper*, String message);
+    static void didReceiveMessageCallback(ScriptExecutionContext*, ThreadableWebSocketChannelClientWrapper*, const String& message);
     static void didStartClosingHandshakeCallback(ScriptExecutionContext*, ThreadableWebSocketChannelClientWrapper*);
     static void didCloseCallback(ScriptExecutionContext*, ThreadableWebSocketChannelClientWrapper*, unsigned long unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to